def toc(self):
        """ Smart getter for Table of Content list.
        """
        toc = []
        stack = [toc]
        for entry in self.__toc:
            entry['sub'] = []
            while entry['level'] < len(stack):
                stack.pop()
            while entry['level'] > len(stack):
                stack.append(stack[-1][-1]['sub'])
            stack[-1].append(entry)
        return toc
def toc ( self ) : toc = [ ] stack = [ toc ] for entry in self . __toc : entry [ 'sub' ] = [ ] while entry [ 'level' ] < len ( stack ) : stack . pop ( ) while entry [ 'level' ] > len ( stack ) : stack . append ( stack [ - 1 ] [ - 1 ] [ 'sub' ] ) stack [ - 1 ] . append ( entry ) return toc
Smart getter for Table of Content list.