from collections import * from LowestCommonAncestor import * def find(root, value): q = deque([root]) while q: currentNode = q.popleft() if currentNode: if currentNode.data == value: return currentNode q.append(currentNode.left) q.append(currentNode.right) if all(val == None for val in q): break return None def main(root, input2, input3): solution = Solution() #tree = BinaryTree(input1) lca = solution.lowest_common_ancestor(root, find(root, input2), find(root, input3)) if lca: return lca.data return -1