def merge(a, b, path=None):

    if path is None: path = []
    for key in b:
        if key in a:
            if isinstance(a[key], dict) and isinstance(b[key], dict):
                merge(a[key], b[key], path + [str(key)])
            elif a[key] == b[key]:
                pass # same leaf value
            else:
                a[key] = b[key]  # prefer b to a
        else:
            a[key] = b[key]
    return a
Implementation of & operator when left operand is not a ParserElement
dataset/ETHPy150Open JeffHeard/sondra/sondra/schema.py/merge--crossover with--dataset/ETHPy150Open ipython/ipython-py3k/IPython/external/pyparsing/_pyparsing.py/ParserElement.__rand__