def test_tree_with_three_nodes(self):
        # test tree with three-nodes
        # this works for left and right nodes, but can't handle the center nodes

        root = lca.Node(79)
        root.left = lca.Node(389)
        root.right = lca.Node(2)
        root.center = lca.Node(10)

        root.left.left = lca.Node(36)
        root.left.right = lca.Node(37)
        root.left.center = lca.Node(29)

        root.right.left = lca.Node(0)
        root.right.right = lca.Node(15)
        root.right.center = lca.Node(89)

        root.center.right = lca.Node(213)
        root.center.left = lca.Node(713)
        root.center.center = lca.Node(23)

        result = lca.find_lca(root, root.left, root.right)
        expected = root

        self.assertEqual(expected, result)

        result2 = lca.find_lca(root, root.center.right, root.center.center)
        expected2 = root.center
        self.assertEqual(expected2, result2)
    def test_very_big_tree(self):
        # test binary tree of height 9

        root = tree(height=9)

        result = lca.find_lca(root, root.right.right.right.right,
                              root.right.right.right.right.right.right.right)
        expected = root.right.right.right.right

        self.assertEqual(expected, result)

        result2 = lca.find_lca(root, root.left.left.right.left,
                               root.left.left.left.right.right)
        expected2 = root.left.left

        self.assertEqual(expected2, result2)
    def test_search_for_all_None_inputs(self):
        # test tree where all input is None

        root = lca.Node(1)
        root.left = lca.Node(2)
        root.right = lca.Node(3)
        root.left.left = lca.Node(4)
        root.left.right = lca.Node(5)
        root.right.left = lca.Node(6)
        root.right.right = lca.Node(7)

        result = lca.LCA_total(None, None, None)
        expected = None

        result = lca.find_lca(root, root.left, root.left.right)
        expected = root.left
        self.assertEqual(expected, result)
    def test_only_left_tree(self):
        # test a tree with only left nodes

        root = lca.Node(7)
        root.left = lca.Node(65)
        root.left.left = lca.Node(3)
        root.left.left.left = lca.Node(92)
        root.left.left.left.left = lca.Node(17)
        root.left.left.left.left.left = lca.Node(37)

        result = lca.LCA_total(root, root.left.left, root.left.left.left.left)
        expected = root.left.left

        self.assertEqual(expected, result)

        result2 = lca.find_lca(root, root.left.left, root.left.left.left)
        expected2 = root.left.left
        self.assertEqual(expected2, result2)