def LCA_Q(ancestor, node1, node2):
    """
    Returns True / False depending on whether the value of ancestor lies
    between node1 and node2, which determines whether it is the least common
    ancestor.
    """
    if node1 < ancestor < node2:
        return True
    elif node2 < ancestor < node1:
        return True
    else:
        return False