def root_hypernyms(self):
        """Retrieves all the root hypernyms.
        
        Returns
        -------
          list of Synsets
        Roots via hypernymy relation.
        
        """
        visited = set()
        hypernyms_next_level = set(self.hypernyms())
        current_hypernyms = set(hypernyms_next_level)

        while len(hypernyms_next_level) > 0:
            current_hypernyms = set(hypernyms_next_level)
            hypernyms_next_level = set()
          
            for synset in current_hypernyms:
                if synset in visited:
                    continue
                visited.add(synset)
                hypernyms_next_level |= set(synset.hypernyms())

        return list(current_hypernyms)
def root_hypernyms ( self ) : visited = set ( ) hypernyms_next_level = set ( self . hypernyms ( ) ) current_hypernyms = set ( hypernyms_next_level ) while len ( hypernyms_next_level ) > 0 : current_hypernyms = set ( hypernyms_next_level ) hypernyms_next_level = set ( ) for synset in current_hypernyms : if synset in visited : continue visited . add ( synset ) hypernyms_next_level |= set ( synset . hypernyms ( ) ) return list ( current_hypernyms )
Retrieves all the root hypernyms.
        
        Returns
        -------
          list of Synsets
        Roots via hypernymy relation.