def union(dict1, dict2):
    for key, value in dict2.items():
        if key in dict1 and isinstance(value, dict):
            dict1[key] = union(dict1[key], value)
        else:
            dict1[key] = value
    return dict1