def lca(root, p, q):
if root is None or root is p or root is q:<EOL><INDENT>return root<EOL><DEDENT>left = lca(root.left, p, q)<EOL>right = lca(root.right, p, q)<EOL>if left is not None and right is not None:<EOL><INDENT>return root<EOL><DEDENT>return left if left else right<EOL>
:type root: TreeNode
:type p: TreeNode
:type q: TreeNode
:rtype: TreeNode