def _deep_merge_dicts(defaults: dict, updates: dict) -> dict:
    """Merges two dicts recursively, with updates taking precendence.

    Note that this modifies defaults in place.
    """
    for k, u in updates.items():
        if k not in defaults:
            defaults[k] = u
        else:
            v = defaults[k]
            if isinstance(u, dict) and isinstance(v, dict):
                defaults[k] = _deep_merge_dicts(v, u)
            else:
                defaults[k] = u

    return defaults