from typing import Mapping


def _update_dict_recursive(base_dict, new_dict):
    """
    Recursively updates a dictionary.

    :param base_dict: The original dictionary that will be updated in place.
    :param new_dict: The dictionary of values to update the original one with.
    :return: The updated dictionary
    """

    for key, val in new_dict.items():
        if isinstance(val, Mapping):
            # if new val is empty, that means delete key
            if not val:
                del base_dict[key]
            else:
                base_dict[key] = _update_dict_recursive(base_dict.get(key, {}), val)
        else:
            base_dict[key] = val
    return base_dict