def METHOD_NAME(obj):
    if isinstance(obj, Error):
        return METHOD_NAME(todict(obj))
    if isinstance(obj, dict):
        result = OrderedDict()
        # Complex objects should be displayed last
        sorted_keys = sorted(obj.keys(), key=lambda k: (isinstance(obj[k], dict), isinstance(obj[k], list), k))
        for key in sorted_keys:
            if obj[key] is None or obj[key] == [] or obj[key] == {}:
                continue
            result[key] = METHOD_NAME(obj[key])
        return result
    if isinstance(obj, list):
        return [METHOD_NAME(v) for v in obj]
    return obj