def format(self, tree):
        """Return a list of string reprs from a nested list of referrers."""
        output = []

        def ascend(branch, depth=1):
            for parent, grandparents in branch:
                output.append(('    ' * depth) + self._format(parent))
                if grandparents:
                    ascend(grandparents, depth + 1)

        ascend(tree)
        return output
Return a list of string reprs from a nested list of referrers.
cherrypy/lib/gctools.py