'Pretty-print the object tree.'

def _pprint_tree(self, max_depth=None, depth=0, f=None):

    indent = ('    |    ' * depth)
    for (idx, token) in enumerate(self.tokens):
        cls = token._get_repr_name()
        value = token._get_repr_value()
        print("{indent}{idx:2d}    {cls}    '{value}'".format(**locals()), file=f)
        if (token.is_group() and ((max_depth is None) or (depth < max_depth))):
            token._pprint_tree(max_depth, (depth + 1), f)
