'Find and return the name of the set containing the object.'

def __getitem__(self, object):

    if (object not in self.parents):
        self.parents[object] = object
        self.weights[object] = 1
        return object
    path = [object]
    root = self.parents[object]
    while (root != path[(-1)]):
        path.append(root)
        root = self.parents[root]
    for ancestor in path:
        self.parents[ancestor] = root
    return root
