def METHOD_NAME(val):
    if isinstance(val, list):
        return [METHOD_NAME(v) for v in val]
    elif isinstance(val, dict):
        return {METHOD_NAME(k): METHOD_NAME(v) for k, v in val.items()}
    elif isinstance(val, (BaseModel, Dict)):
        return val.dict(
            exclude_unset=True,
            exclude_defaults=True)
    elif isinstance(val, List):
        return val.dict(
            exclude_unset=True,
            exclude_defaults=True)['__root__']
    else:
        return val