code: def closure(self, relation, depth=float('inf')):   
          
      
          ancestors = []
          unvisited_ancestors = [(synset,1) for synset in self.get_related_synsets(relation)]
  
          while len(unvisited_ancestors) > 0:
              ancestor_depth = unvisited_ancestors.pop()
              if ancestor_depth[1] > depth:
                  continue    
              unvisited_ancestors.extend([(synset,ancestor_depth[1]+1) for synset in ancestor_depth[0].get_related_synsets(relation)])
              ancestors.append(ancestor_depth[0])
  
          return list(set(ancestors))
docs: Finds all the ancestors of the synset using provided relation.
  
          Parameters
          ----------
            relation : str
          Name of the relation which is recursively used to fetch the ancestors.
  
          Returns
          -------
            list of Synsets
          Returns the ancestors of the synset via given relations.