def override_dict(defaults, overrides):
    """
    Override a dictionary with values in another dictionary. This will
    recursively descend into matching nested dictionaries.

    :param dict defaults: The original values.
    :param dict overrides: The overriding values.
    :return: The modified ``params`` dictionary.
    :rtype: Dict
    """
    for (key, value) in overrides.items():
        if isinstance(value, dict):
            # NOTE: if the parameter already exists, we can only use it as a
            # default value if it is a dictionary.
            if key in defaults and isinstance(defaults[key], dict):
                sub_defaults = defaults[key]
            else:
                sub_defaults = {}
            defaults[key] = override_dict(sub_defaults, value)
        else:
            defaults[key] = value
    return defaults