'Returns a string listing all errors within a document'

def _format_errors(self):

    def generate_key(value, prefix=''):
        if isinstance(value, list):
            value = '    '.join([generate_key(k) for k in value])
        elif isinstance(value, dict):
            value = '    '.join([generate_key(v, k) for (k, v) in value.iteritems()])
        results = (('%s.%s' % (prefix, value)) if prefix else value)
        return results
    error_dict = defaultdict(list)
    for (k, v) in self.to_dict().iteritems():
        error_dict[generate_key(v)].append(k)
    return '    '.join([('%s:    %s' % (k, v)) for (k, v) in error_dict.iteritems()])
