code: def find_parents(self):
          
          for i in range(len(self.vertices)):
              self.vertices[i].parents = []
          for i in range(len(self.vertices)):
              for child in self.vertices[i].children:
                  if i not in self.vertices[child].parents:
                      self.vertices[child].parents.append(i)
docs: Take a tree and set the parents according to the children
  
          Takes a tree structure which lists the children of each vertex
          and computes the parents for each vertex and places them in.