'Collect the relative links (next, previous, up) for each "node".'

def collect_rellinks(self):

    rellinks = self.rellinks
    node_menus = self.node_menus
    for (id, entries) in node_menus.items():
        rellinks[id] = ['', '', '']
    for (id, entries) in node_menus.items():
        for e in entries:
            rellinks[e][2] = id
    for (id, entries) in node_menus.items():
        for (i, id) in enumerate(entries):
            if (i != 0):
                rellinks[id][1] = entries[(i - 1)]
            if (i != (len(entries) - 1)):
                rellinks[id][0] = entries[(i + 1)]
    try:
        first = node_menus['Top'][0]
    except IndexError:
        pass
    else:
        rellinks['Top'][0] = first
        rellinks[first][1] = 'Top'
