def deep_update(d, u):
for k, v in u.items():<EOL><INDENT>if isinstance(v, Mapping):<EOL><INDENT>d[k] = deep_update(d.get(k, {}), v)<EOL><DEDENT>elif isinstance(v, list):<EOL><INDENT>existing_elements = d.get(k, [])<EOL>d[k] = existing_elements + [ele for ele in v if ele not in existing_elements]<EOL><DEDENT>else:<EOL><INDENT>d[k] = v<EOL><DEDENT><DEDENT>return d<EOL>
Deeply updates a dictionary. List values are concatenated.

    Args:
      d (dict): First dictionary which will be updated
      u (dict): Second dictionary use to extend the first one

    Returns:
      dict: The merge dictionary