def deep_merge(base, changes):
    """
    Create a copy of ``base`` dict and recursively merges the ``changes`` dict.

    Returns merged dict.

    :type base: dict
    :param base: The base dictionary for the merge
    :type changes: dict
    :param changes: The dictionary to merge into the base one
    :return: The merged ``result`` dict
    """
    def merge(result, changes):
        for k, v in changes.items():
            if not isinstance(v, dict):
                result[k] = v
            else:
                if k not in result or not isinstance(result[k], dict):
                    result[k] = v.copy()
                else:
                    result[k] = result[k].copy()
                    merge(result[k], changes[k])

    result = base.copy()
    merge(result, changes)
    return result