from typing import Mapping


def deep_update(origdict, newdict):
    """Update a dictionary in place, recursing to do a deep copy.
    """
    for key, value in newdict.items():
        if isinstance(value, Mapping):
            origdict[key] = deep_update(origdict.get(key, {}), value)

        else:
            origdict[key] = value

    return origdict