If a and b are not from same set
if ( a != b ) : NEW_LINE INDENT if ( Size [ a ] < Size [ b ] ) : NEW_LINE INDENT a , b = b , a NEW_LINE DEDENT parent [ b ] = a NEW_LINE Size [ a ] += Size [ b ] NEW_LINE DEDENT