from copy import deepcopy


def assoc_deep_kw(obj, **kwargs):
    """ Deep Copy obj and __setitem__ all kwargs on the new object, return it. """

    # special case None to work like empty dict
    if obj is None:
        obj = {}
    else:
        obj = deepcopy(obj)

    for k, v in kwargs.items():
        obj[k] = v

    return obj