We will start traversing from the **root node ' r'** of the Binary Search Tree(BST).

Let

**v**and

**w**be the nodes we are looking the LCA for.

We assume v and w will be present in the BST.

**Note : In a BST, if node n1 is greater than node n , it will be to the right of n and if its smaller than n, it will be to the left of n.**

We can use this property and traverse recursively from root to look for LCA of v and w.

If v and w are greater than r, we will traverse recursively to the right.

If v and w are smaller than r, we will traverse recursively to the right.

Else, root is the LCA.

```
# Function to find LCA of v and w.
def lca(root, v, w):
# Base Case
if root is None:
return None
# If both v and w are smaller than root, then LCA lies in left
if(root.data > v and root.data > w):
return lca(root.left, v, w)
# If both v and w are greater than root, then LCA lies in right
if(root.data < v and root.data < w):
return lca(root.right, v, w)
return root
```