Tree: Depth-First Search - Lowest Common Ancestor of Binary Tree
Consider the recursive DFS approach to find LCA. What does the function return when called on a tree with a single node (value 1) and both p and q are that node?
Code snippet:
```python
def lowestCommonAncestor(root, p, q):
if not root:
return None
if root == p or root == q:
return root
left = lowestCommonAncestor(root.left, p, q)
right = lowestCommonAncestor(root.right, p, q)
if left and right:
return root
return left if left else right
```
