'Diagnostic method for listing out the contents of a C{ParseResults}.
Accepts an optional C{indent} argument so that this string can be embedded
in a nested display of other data.'

def dump(self, indent='', depth=0):

    out = []
    NL = '\n'
    out.append((indent + _ustr(self.asList())))
    if self.haskeys():
        items = sorted(self.items())
        for (k, v) in items:
            if out:
                out.append(NL)
            out.append(('%s%s-    %s:    ' % (indent, ('        ' * depth), k)))
            if isinstance(v, ParseResults):
                if v:
                    out.append(v.dump(indent, (depth + 1)))
                else:
                    out.append(_ustr(v))
            else:
                out.append(_ustr(v))
    elif any((isinstance(vv, ParseResults) for vv in self)):
        v = self
        for (i, vv) in enumerate(v):
            if isinstance(vv, ParseResults):
                out.append(('\n%s%s[%d]:\n%s%s%s' % (indent, ('        ' * depth), i, indent, ('        ' * (depth + 1)), vv.dump(indent, (depth + 1)))))
            else:
                out.append(('\n%s%s[%d]:\n%s%s%s' % (indent, ('        ' * depth), i, indent, ('        ' * (depth + 1)), _ustr(vv))))
    return ''.join(out)
