parameters: (self, object)
return_statement: return root
docstring: Find and return the name of the set containing the object.
docstring_summary: Find and return the name of the set containing the object.
docstring_tokens: Find and return the name of the set containing the object .
function: def __getitem__(self, object):
          """Find and return the name of the set containing the object."""
  
          # check for previously unknown object
          if object not in self.parents:
              self.parents[object] = object
              self.weights[object] = 1
              return object
  
          # find path of objects leading to the root
          path = [object]
          root = self.parents[object]
          while root != path[-1]:
              path.append(root)
              root = self.parents[root]
  
          # compress the path and return
          for ancestor in path:
              self.parents[ancestor] = root
          return root
function_tokens: def __getitem__ ( self , object ) : # check for previously unknown object if object not in self . parents : self . parents [ object ] = object self . weights [ object ] = 1 return object # find path of objects leading to the root path = [ object ] root = self . parents [ object ] while root != path [ - 1 ] : path . append ( root ) root = self . parents [ root ] # compress the path and return for ancestor in path : self . parents [ ancestor ] = root return root