When v and u are on the same level but are in different subtree . Now move both u and v up by 1 till they are not same
while ( v != u ) : NEW_LINE INDENT if ( prime [ weight [ v ] ] ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT if ( prime [ weight [ u ] ] ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT u = par [ u ] NEW_LINE v = par [ v ] NEW_LINE DEDENT