def merge(first, second):
    '\n    Recursively merges two dictionaries.\n\n    Second dictionary values will take precedence over those from the first one.\n    Nested dictionaries are merged too.\n\n    :param dict first: The first dictionary\n    :param dict second: The second dictionary\n    :return: the resulting merged dictionary\n    :rtype: dict\n    '
    if (not isinstance(second, dict)):
        return second
    result = deepcopy(first)
    for (key, value) in second.items():
        if ((key in result) and isinstance(result[key], dict)):
            result[key] = merge(result[key], value)
        else:
            result[key] = deepcopy(value)
    return result
Recursively merges two dictionaries.

Second dictionary values will take precedence over those from the first one.
Nested dictionaries are merged too.

:param dict first: The first dictionary
:param dict second: The second dictionary
:return: the resulting merged dictionary
:rtype: dict
def merge(first, second):
    '\n    Recursively merges two dictionaries.\n\n    Second dictionary values will take precedence over those from the first one.\n    Nested dictionaries are merged too.\n\n    :param dict first: The first dictionary\n    :param dict second: The second dictionary\n    :return: the resulting merged dictionary\n    :rtype: dict\n    '
    if (not isinstance(second, dict)):
        return second
    result = deepcopy(first)
    for (key, value) in second.items():
        if ((key in result) and isinstance(result[key], dict)):
            result[key] = merge(result[key], value)
        else:
            result[key] = deepcopy(value)
    return result