import copy


def compose(a, b, keep_null=False):
    """
    Compose two operations into one.

    ``keep_null`` [default=false] is a boolean that controls whether None/Null 
    attributes are retrained.
    """
    if a is None:
        a = {}
    if b is None:
        b = {}

    # deep copy b, but get rid of None values if keep_null is falsey
    attributes = dict((k, copy.deepcopy(v)) for k, v in b.items() if keep_null or v is not None)

    for k, v in a.items():
        if k not in b:
            attributes[k] = copy.deepcopy(v)

    return attributes or None