Recursively merge two data structures.

    :param unique: When set to True existing list items are not set.
967911
def object_merge(old, new, unique=False):
    
    if isinstance(old, list) and isinstance(new, list):
        if old == new:
            return
        for item in old[::-1]:
            if unique and item in new:
                continue
            new.insert(0, item)
    if isinstance(old, dict) and isinstance(new, dict):
        for key, value in old.items():
            if key not in new:
                new[key] = value
            else:
                object_merge(value, new[key])
652561
def merge_lists(l, base):
    
    
    for i in base:
        if i not in l:
            l.append(i)
270764
def _list_merge(src, dest):
    
    for k in src:
        if type(src[k]) != dict:
            dest[k] = src[k]
        else:
            # ---
            # src could have a key whose value is a list
            # and does not yet exist on dest
            if k not in dest:
                dest[k] = {}
            _list_merge(src[k], dest[k])
964181
def inverable_group_multi_list(item_lists):
    
    #unique_list1, inverse1 = np.unique(item1_list, return_index=True, return_inverse=True)
    import vtool as vt
    import utool as ut
    # Find uniques and groups in each individual list
    unique_lists = []
    groupx_lists = []
    for item_list in item_lists:
        unique_items, groupxs = vt.group_indices(item_list)
        unique_lists.append(unique_items)
        groupx_lists.append(groupxs)
    # Merge all indexes into a signle long list
    groups_stacked = ut.flatten(groupx_lists)
    flat_stacked, cumsum = ut.invertible_flatten2(unique_lists)
    # Find uniques in those lists
    flat_unique, stack_groups = vt.group_indices(np.array(flat_stacked))
    # Get a list of corresonding group indicies from each input list
    flat_groupx_multilist = [ut.take(groups_stacked, groupx) for groupx in stack_groups]
    # flat_unique corresponds with the aids (hence chips) the flag_groupxs
    # multilist is a list where each item is a tuple who's nth item indexes
    # into the nth input list. Ie (1, 0) is a list of indexes into the 1st chip
    # the 0th keypoint list
    return flat_unique, flat_groupx_multilist
57133
private void mergeResponsesSortedSet(SortedSet<Object> originalList, SortedSet<Object> shardList) {
		for (Object item : shardList) {
			originalList.add(item);
		}
	}
420558
def unique(list1, list2):
    
    set2 = set(list2)
    list1_unique = [x for x in tqdm(list1, desc='Unique', total=len(list1)) if x not in set2]
    return list1_unique
729802
def _merge_list(self, key, lst):
    
    self[key] += [x for x in lst if x not in self[key]]
640878
def merge_sources(self, datas):
        
        datas = [data for data in datas if data is not None]

        if len(datas) == 0:
            raise ValueError("Data missing")

        if len(datas) == 1:
            return datas[0]

        if isinstance(datas[0], list):
            if len([x for x in datas if not isinstance(x, list)]) > 0:
                raise TypeError("Unable to merge: List expected")
            base = []
            for x in datas:
                base = base + x
            return base

        if isinstance(datas[0], dict):
            if len([x for x in datas if not isinstance(x, dict)]) > 0:
                raise TypeError("Unable to merge: Dictionnary expected")
            result = {}
            for element in datas:
                for key in element:
                    if key in result:
                        result[key] = self.merge_sources([result[key], element[key]])
                    else:
                        result[key] = element[key]
            return result

        if len([x for x in datas if isinstance(x, (dict, list))]) > 0:
            raise TypeError("Unable to merge: List not expected")

        raise ValueError("Unable to merge: Conflict")
1363077
def uniqify(list_):
  ""
  a=[]
  for x in list_:
    if x not in a: a.append(x)
  return a
577254
def unique(lst):
    
    lst = lst[:]
    unique_lst = []

    # Cycle through the list and add each value to the unique list only once.
    for item in lst:
        if unique_lst.count(item) <= 0:
            unique_lst.append(item)
            
    # Return the list with all redundant values removed.
    return unique_lst
601747
def unique(iterable):
    
    seen = set()
    return [x for x in iterable if x not in seen and not seen.add(x)]
137078
def unique(iterable):
    

    yielded = set()
    for i in iterable:
        if i in yielded:
            continue
        yield i
        yielded.add(i)
1326606
def unique_list(input_list):
    
    """
    output_list = []
    if len(input_list) > 0:
        dim = _sp.shape(input_list)[1]
        for i in input_list:
            match = False
            for j in output_list:
                if dim == 3:
                    if i[0] == j[0] and i[1] == j[1] and i[2] == j[2]:
                        match = True
                elif dim == 2:
                    if i[0] == j[0] and i[1] == j[1]:
                        match = True
                elif dim == 1:
                    if i[0] == j[0]:
                        match = True
            if match is False:
                output_list.append(i)
    return output_list
1107268
def merge_dicts(dict_a, dict_b):
    """"""
    duplicates = [val for val in dict_a if val in dict_b]
    if duplicates:
        _LOGGER.warning(("Duplicates found during merge: %s. "
                         "Renaming is recommended."), duplicates)
    return {**dict_a, **dict_b}
1017127
def _perform_merge(self, other):
        
        if len(other.value) > len(self.value):
            self.value = other.value[:]
        return True
249877
def merge(self, dest, *others):
        
        items = [self.key]
        items.extend([other.key for other in others])
        self.database.pfmerge(dest, *items)
        return HyperLogLog(self.database, dest)
525299
def merge(left, right):
    
    merged = {}

    left_keys = frozenset(left)
    right_keys = frozenset(right)

    # Items only in the left Mapping
    for key in left_keys - right_keys:
        merged[key] = left[key]

    # Items only in the right Mapping
    for key in right_keys - left_keys:
        merged[key] = right[key]

    # in both
    for key in left_keys & right_keys:
        left_value = left[key]
        right_value = right[key]

        if (isinstance(left_value, Mapping) and
                isinstance(right_value, Mapping)):  # recursive merge
            merged[key] = merge(left_value, right_value)
        else:  # overwrite with right value
            merged[key] = right_value

    return merged