Python simple solution:

```
class Solution(object):
def lowestCommonAncestor(self, root, p, q):
if q.val<p.val:
return self.lowestCommonAncestor(root,q,p)
if p.val<=root.val<=q.val:
return root
elif q.val<root.val:
return self.lowestCommonAncestor(root.left,p,q)
else:
return self.lowestCommonAncestor(root.right,p,q)
```