code: def build_full_toctree(builder, docname, prune, collapse):
      
      env = builder.env
      doctree = env.get_doctree(env.config.master_doc)
      toctrees = []
      for toctreenode in doctree.traverse(addnodes.toctree):
          toctree = env.resolve_toctree(docname, builder, toctreenode,
                                        collapse=collapse,
                                        prune=prune,
                                        )
          toctrees.append(toctree)
      if not toctrees:
          return None
      result = toctrees[0]
      for toctree in toctrees[1:]:
          if toctree:
              result.extend(toctree.children)
      env.resolve_references(result, docname, builder)
      return result
docs: Return a single toctree starting from docname containing all
      sub-document doctrees.