def _collapse_list_of_sets(self, sets):
        '''Input is a list of sets. Merges any intersecting sets in the list'''
        found = True
        while found:
            found = False
            to_intersect = None
            for i in range(len(sets)):
                for j in range(len(sets)):
                    if i == j:
                        continue
                    elif sets[i].intersection(sets[j]):
                        to_intersect = i, j
                        break

                if to_intersect is not None:
                    break

            if to_intersect is not None:
                found = True
                sets[i].update(sets[j])
                sets.pop(j)

        return sets
def _collapse_list_of_sets ( self , sets ) : found = True while found : found = False to_intersect = None for i in range ( len ( sets ) ) : for j in range ( len ( sets ) ) : if i == j : continue elif sets [ i ] . intersection ( sets [ j ] ) : to_intersect = i , j break if to_intersect is not None : break if to_intersect is not None : found = True sets [ i ] . update ( sets [ j ] ) sets . pop ( j ) return sets
Input is a list of sets. Merges any intersecting sets in the list