deflowestCommonAncestor(root: TreeNode, p: TreeNode, q: TreeNode)-> TreeNode:ifnot root or root == p or root == q:return root
left = lowestCommonAncestor(root.left, p, q)
right = lowestCommonAncestor(root.right, p, q)ifnot left:return right
ifnot right:return left
return root