Finding the ancestor of v which is at same level as u
i = lg - 1 NEW_LINE while ( i >= 0 ) : NEW_LINE INDENT if ( lca [ v ] [ i ] != - 1 and level [ lca [ v ] [ i ] ] >= level [ u ] ) : NEW_LINE DEDENT