<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def closure(self, relation, depth=float('inf')):
 """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. """

    
        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))