'Debug helper method that returns a recursive string representation of this node.'

def dump(self, level=0, filter_out=('pos',), cutoff=100, encountered=None):

    if (cutoff == 0):
        return '<...nesting    level    cutoff...>'
    if (encountered is None):
        encountered = set()
    if (id(self) in encountered):
        return ('<%s    (0x%x)    --    already    output>' % (self.__class__.__name__, id(self)))
    encountered.add(id(self))
    def dump_child(x, level):
        if isinstance(x, Node):
            return x.dump(level, filter_out, (cutoff - 1), encountered)
        elif isinstance(x, list):
            return ('[%s]' % ',    '.join([dump_child(item, level) for item in x]))
        else:
            return repr(x)
    attrs = [(key, value) for (key, value) in self.__dict__.items() if (key not in filter_out)]
    if (len(attrs) == 0):
        return ('<%s    (0x%x)>' % (self.__class__.__name__, id(self)))
    else:
        indent = ('        ' * level)
        res = ('<%s    (0x%x)\n' % (self.__class__.__name__, id(self)))
        for (key, value) in attrs:
            res += ('%s        %s:    %s\n' % (indent, key, dump_child(value, (level + 1))))
        res += ('%s>' % indent)
        return res
