import copy


def merge(one, two):
    """
    Merge two dictionaries with dictionaries in them. Keys that occur in both are taken from the
    second argument.
    """
    ret = copy.copy(one)
    for key in two:
        if key in one:
            if isinstance(one[key], dict) and isinstance(two[key], dict):
                ret[key] = merge(one[key], two[key])
            else:
                ret[key] = two[key]
        else:
            ret[key] = two[key]
    return ret