from typing import Union


def recursive_clean(d: dict) -> Union[dict, None]:
    """recursively clean a dictionary d which might contain nested sub-dictionaries, i.e. remove None-entries"""

    new_dict = {}
    for k, v in d.items():
        if isinstance(v, dict):
            v = recursive_clean(v)
        if v is not None:
            new_dict[k] = v
    return new_dict or None