def METHOD_NAME(result, obj, indent):
    if not obj:
        result.append('{}')
        return
    obj = sorted(obj.items())
    multiline = indent and (
        len(obj) > 2
        or len(obj) == 2
        and (
            isinstance(obj[0][-1], (list, dict))
            or isinstance(obj[-1][-1], (list, dict))
        )
    )
    if not multiline and (not indent or len(obj) != 1):
        result.append('{')
        obj = [[x, ', '] for x in obj]
        obj[-1][-1] = '}'
        for (key, value), separator in obj:
            dumprecurse(result, key, '')
            result.append(': ')
            dumprecurse(result, value, '')
            result.append(separator)
        return
    doindent = len(obj) > 1
    for key, value in obj:
        dumprecurse(result, key, indent, doindent)
        result.append(': ')
        dumprecurse(result, value, indent + '    ', False)