def ancestor(synset1, synset2):
 (h1, h2) = (synset1.hypernyms(recursive=True), synset2.hypernyms(recursive=True))
 for s in h1:
  if (s in h2):
   return s

def ancestor ( synset1 , synset2 ) : ( h1 , h2 ) = ( synset1 . hypernyms ( recursive = True ) , synset2 . hypernyms ( recursive = True ) ) for s in h1 : if ( s in h2 ) : return s
returns the common ancestor of both synsets .