def lowest_common_ancestor(root, a, b):
    """ lowest common ancestor in BST """
    if root.data > max(a, b):
        return lowest_common_ancestor(root.left, a, b)
    if root.data < min(a, b):
        return lowest_common_ancestor(root.right, a, b)
    return root