Calculating level of nodes
lvl [ u ] = 1 + lvl [ p ] NEW_LINE if ( lvl [ u ] > maxi ) : NEW_LINE INDENT maxi = lvl [ u ] NEW_LINE end1 = u NEW_LINE DEDENT for i in range ( len ( adj [ u ] ) ) : NEW_LINE