def lowestCommonAncestor(self, root, A, B):
    if ((root is None) or (root is A) or (root is B)):
        return root
    left = self.lowestCommonAncestor(root.left, A, B)
    right = self.lowestCommonAncestor(root.right, A, B)
    if (left and right):
        return root
    if left:
        return left
    return right
def lowestCommonAncestor(self, root, A, B):
    if ((root is None) or (root is A) or (root is B)):
        return root
    left = self.lowestCommonAncestor(root.left, A, B)
    right = self.lowestCommonAncestor(root.right, A, B)
    if (left and right):
        return root
    if left:
        return left
    return right