'Read the doctree from the pickle, resolve cross-references and
toctrees and return it.'

def get_and_resolve_doctree(self, docname, builder, doctree=None, prune_toctrees=True):

    if (doctree is None):
        doctree = self.get_doctree(docname)
    self.resolve_references(doctree, docname, builder)
    for toctreenode in doctree.traverse(addnodes.toctree):
        result = self.resolve_toctree(docname, builder, toctreenode, prune=prune_toctrees)
        if (result is None):
            toctreenode.replace_self([])
        else:
            toctreenode.replace_self(result)
    return doctree
