from typing import Mapping


def _recursive_update(d, u):
    """Recursively update a nested dict with another."""
    # https://stackoverflow.com/a/3233356/1595060
    for k, v in u.items():
        if isinstance(v, Mapping):
            d[k] = _recursive_update(d.get(k, {}), v)
        else:
            d[k] = v
    return d