def __iter__(self):
      """Returns an iterator returning each of the disjoint sets as a list."""
      seen = set()
      for elem, group in self._mapping.iteritems():
          if elem not in seen:
              yield group
              seen.update(group)
Returns an iterator returning each of the disjoint sets as a list.
recipes/Python/387776_Grouping_objects_indisjoint/recipe-387776.py