def lca_bst(root, value1, value2):
    while root is not None:
        if value2 > root.data < value1:
            root = root.right
        elif value2 < root.data > value1:
            root = root.left
        else:
            return root.data