'Collect the menu entries for each "node" section.'

def collect_node_menus(self):

    node_menus = self.node_menus
    for node in ([self.document] + self.document.traverse(nodes.section)):
        assert (('node_name' in node) and node['node_name'])
        entries = [s['node_name'] for s in find_subsections(node)]
        node_menus[node['node_name']] = entries
    title = self.document.next_node(nodes.title)
    top = ((title and title.parent) or self.document)
    if (not isinstance(top, (nodes.document, nodes.section))):
        top = self.document
    if (top is not self.document):
        entries = node_menus[top['node_name']]
        entries += node_menus['Top'][1:]
        node_menus['Top'] = entries
        del node_menus[top['node_name']]
        top['node_name'] = 'Top'
    for (name, content) in self.indices:
        node_menus[name] = []
        node_menus['Top'].append(name)
