code: def union(self, i, j):
          '''
          API:
              union(self, i, j):
          Description:
              Finds sets of i and j and unites them.
          Input:
              i: Item.
              j: Item.
          Post:
              self.sizes will be updated.
          '''
          roots = (self.find(i), self.find(j))
          if roots[0] == roots[1]:
              return False
          if self.sizes[roots[0]] <= self.sizes[roots[1]] or not self.optimize:
              self.add_edge(roots[0], roots[1])
              self.sizes[roots[1]] += self.sizes[roots[0]]
              return True
          else:
              self.add_edge(roots[1], roots[0])
              self.sizes[roots[0]] += self.sizes[roots[1]]
              return Truf union(self, i, j):
          '''
          API:
              union(self, i, j):
          Description:
              Finds sets of i and j and unites them.
          Input:
              i: Item.
              j: Item.
          Post:
              self.sizes will be updated.
          '''
          roots = (self.find(i), self.find(j))
          if roots[0] == roots[1]:
              return False
          if self.sizes[roots[0]] <= self.sizes[roots[1]] or not self.optimize:
              self.add_edge(roots[0], roots[1])
              self.sizes[roots[1]] += self.sizes[roots[0]]
              return True
          else:
              self.add_edge(roots[1], roots[0])
              self.sizes[roots[0]] += self.sizes[roots[1]]
              return True
docs: API:
              union(self, i, j):
          Description:
              Finds sets of i and j and unites them.
          Input:
              i: Item.
              j: Item.
          Post:
              self.sizes will be updated.