def deep_merge(a, b):
    """
    Merges b into a, recursively.
    This is a special recursive dictionary merge, made specifically for docker compose files.
    If a and b are both dictionaries, their keys are recursively merged. Keys in b write over keys in a.
    If a and b are both lists, the elements of b are added to a. Duplicate values are removed.
    If a and b are any other types, b is returned.
    :param a: Any object.
    :param b: Any object.
    :return: b merged into a.
    """

    if isinstance(a, dict) and isinstance(b, dict):
        for key in b:
            if key in a:
                a[key] = deep_merge(a[key], b[key])
            else:
                a[key] = b[key]
        return a
    elif isinstance(a, list) and isinstance(b, list):
        # Add all elements of b to a
        return list(set(a + b))
    elif b is None:
        return a
    else:
        # Copy b's value into a.
        return b