def distance(u, v, ancestor):
    """
    Computes distance of the path from u to v using the lca node as:
        d(u,v) = d(root, u) + d(root, v) - 2 * d(root, lca)
    :param u:
    :param v:
    :param ancestor:
    :return:
    """
    dru = u.depth
    drv = v.depth
    drlca = ancestor.depth

    return dru + drv - 2 * drlca