'Return the global TOC nodetree.'

def get_toctree_for(self, docname, builder, collapse, **kwds):

    doctree = self.env.get_doctree(self.env.config.master_doc)
    toctrees = []
    if ('includehidden' not in kwds):
        kwds['includehidden'] = True
    if ('maxdepth' not in kwds):
        kwds['maxdepth'] = 0
    kwds['collapse'] = collapse
    for toctreenode in doctree.traverse(addnodes.toctree):
        toctree = self.resolve(docname, builder, toctreenode, prune=True, **kwds)
        if toctree:
            toctrees.append(toctree)
    if (not toctrees):
        return None
    result = toctrees[0]
    for toctree in toctrees[1:]:
        result.extend(toctree.children)
    return result
