'>>> from nltk.corpus import wordnet as wn
>>> dog = wn.synset(\'dog.n.01\')
>>> hyp = lambda s:s.hypernyms()
>>> from pprint import pprint
>>> pprint(dog.tree(hyp))
[Synset(\'dog.n.01\'),
[Synset(\'canine.n.02\'),
[Synset(\'carnivore.n.01\'),
[Synset(\'placental.n.01\'),
[Synset(\'mammal.n.01\'),
[Synset(\'vertebrate.n.01\'),
[Synset(\'chordate.n.01\'),
[Synset(\'animal.n.01\'),
[Synset(\'organism.n.01\'),
[Synset(\'living_thing.n.01\'),
[Synset(\'whole.n.02\'),
[Synset(\'object.n.01\'),
[Synset(\'physical_entity.n.01\'),
[Synset(\'entity.n.01\')]]]]]]]]]]]]],
[Synset(\'domestic_animal.n.01\'),
[Synset(\'animal.n.01\'),
[Synset(\'organism.n.01\'),
[Synset(\'living_thing.n.01\'),
[Synset(\'whole.n.02\'),
[Synset(\'object.n.01\'),
[Synset(\'physical_entity.n.01\'), [Synset(\'entity.n.01\')]]]]]]]]]'

def tree(self, rel, depth=(-1), cut_mark=None):

    tree = [self]
    if (depth != 0):
        tree += [x.tree(rel, (depth - 1), cut_mark) for x in rel(self)]
    elif cut_mark:
        tree += [cut_mark]
    return tree
