code: def parseBranches(self, descendants):
          
          i, branches = self.parseTopDepth(descendants), []
          for descendant in descendants:
              if self.getHeadingLevel(descendant, self.hierarchy) == i:
                  branches.append({'source': descendant})
              if self.getHeadingLevel(descendant, self.hierarchy) > i \
                  and branches:
                  branches[-1].setdefault('descendants', []).append(descendant)
          return [TOC(str(descendant), depth=i, hierarchy=self.hierarchy,
              **branch) for branch in branches]
docs: Parse top level of latex
          :param list elements: list of source objects
          :return: list of filtered TreeOfContents objects
  
          >>> toc = TOC.fromLatex(r'\section{h1}\subsection{subh1}\section{h2}\
          ... \subsection{subh2}')
          >>> toc.parseTopDepth(toc.descendants)
          1
          >>> toc.parseBranches(toc.descendants)
          [h1, h2]
          >>> len(toc.branches)
          2
          >>> len(toc.section.branches)
          1