Takes a dictionary, max_val_size and replace_with
    and recursively loops through and replaces any values
    that are greater than max_val_size.
198410
def _trim_dict_in_dict(data, max_val_size, replace_with):
    '''
    
    '''
    for key in data:
        if isinstance(data[key], dict):
            _trim_dict_in_dict(data[key],
                               max_val_size,
                               replace_with)
        else:
            if sys.getsizeof(data[key]) > max_val_size:
                data[key] = replace_with
9248
def _strip_key(dictionary, keyword):
    '''
    
    '''

    for key, value in six.iteritems(dictionary):
        if key == keyword:
            dictionary[key] = None
        elif isinstance(value, dict):
            _strip_key(value, keyword)
        elif isinstance(value, list):
            for item in value:
                if isinstance(item, dict):
                    _strip_key(item, keyword)

    return dictionary
946055
def patch_splitMax(self, patches):
    
    patch_size = self.Match_MaxBits
    if patch_size == 0:
      # Python has the option of not splitting strings due to its ability
      # to handle integers of arbitrary precision.
      return
    for x in range(len(patches)):
      if patches[x].length1 <= patch_size:
        continue
      bigpatch = patches[x]
      # Remove the big old patch.
      del patches[x]
      x -= 1
      start1 = bigpatch.start1
      start2 = bigpatch.start2
      precontext = ''
      while len(bigpatch.diffs) != 0:
        # Create one of several smaller patches.
        patch = patch_obj()
        empty = True
        patch.start1 = start1 - len(precontext)
        patch.start2 = start2 - len(precontext)
        if precontext:
          patch.length1 = patch.length2 = len(precontext)
          patch.diffs.append((self.DIFF_EQUAL, precontext))

        while (len(bigpatch.diffs) != 0 and
               patch.length1 < patch_size - self.Patch_Margin):
          (diff_type, diff_text) = bigpatch.diffs[0]
          if diff_type == self.DIFF_INSERT:
            # Insertions are harmless.
            patch.length2 += len(diff_text)
            start2 += len(diff_text)
            patch.diffs.append(bigpatch.diffs.pop(0))
            empty = False
          elif (diff_type == self.DIFF_DELETE and len(patch.diffs) == 1 and
              patch.diffs[0][0] == self.DIFF_EQUAL and
              len(diff_text) > 2 * patch_size):
            # This is a large deletion.  Let it pass in one chunk.
            patch.length1 += len(diff_text)
            start1 += len(diff_text)
            empty = False
            patch.diffs.append((diff_type, diff_text))
            del bigpatch.diffs[0]
          else:
            # Deletion or equality.  Only take as much as we can stomach.
            diff_text = diff_text[:patch_size - patch.length1 -
                                  self.Patch_Margin]
            patch.length1 += len(diff_text)
            start1 += len(diff_text)
            if diff_type == self.DIFF_EQUAL:
              patch.length2 += len(diff_text)
              start2 += len(diff_text)
            else:
              empty = False

            patch.diffs.append((diff_type, diff_text))
            if diff_text == bigpatch.diffs[0][1]:
              del bigpatch.diffs[0]
            else:
              bigpatch.diffs[0] = (bigpatch.diffs[0][0],
                                   bigpatch.diffs[0][1][len(diff_text):])

        # Compute the head context for the next patch.
        precontext = self.diff_text2(patch.diffs)
        precontext = precontext[-self.Patch_Margin:]
        # Append the end context for this patch.
        postcontext = self.diff_text1(bigpatch.diffs)[:self.Patch_Margin]
        if postcontext:
          patch.length1 += len(postcontext)
          patch.length2 += len(postcontext)
          if len(patch.diffs) != 0 and patch.diffs[-1][0] == self.DIFF_EQUAL:
            patch.diffs[-1] = (self.DIFF_EQUAL, patch.diffs[-1][1] +
                               postcontext)
          else:
            patch.diffs.append((self.DIFF_EQUAL, postcontext))

        if not empty:
          x += 1
          patches.insert(x, patch)
806911
def recursively_update(d, d2):
  """"""
  for k, v in d2.items():
    if k in d:
      if isinstance(v, dict):
        recursively_update(d[k], v)
        continue
    d[k] = v
838247
private void fixupMaxWithComparator(int k) {
        K key = array[k];
        int gp = k / 4;
        while (gp > 0 && comparator.compare(array[gp], key) < 0) {
            array[k] = array[gp];
            k = gp;
            gp = k / 4;
        }
        array[k] = key;
    }
205922
def replace(self, old, new, variable_set=None, leaf_operation=None):   # pylint:disable=unused-argument
        
        self._check_replaceability(old, new)
        replacements = {old.cache_key: new}
        return self.replace_dict(replacements, variable_set=old.variables)
50276
def _patch_dict(diff, base):
    
    for k, v in diff.items():
        if isinstance(v, dict):
            base[k] = _patch_dict(v, base.get(k, {}))
        elif not v:
            base.pop(k, None)
        else:
            base[k] = v
    return base
1141117
def dict_values(src):
    
    for v in src.values():
        if isinstance(v, dict):
            for v in dict_values(v):
                yield v
        else:
            yield v
567800
def update(self, dictionary):
        """"""
        allowed_attrs = list(self.__attributes__.keys())
        allowed_attrs += [a.alias for a in self.__attributes__.values()]
        for k in dictionary:
            # We only update existing attributes
            if k in allowed_attrs:
                setattr(self, k, dictionary[k])
        return self
1353318
def _update(self, data):
        """"""
        for k, v in six.iteritems(data):
            new_value = v
            if isinstance(v, dict):
                new_value = type(self)(v)
            elif isinstance(v, list):
                new_value = [(type(self)(e) if isinstance(e, dict) else e)
                             for e in v]
            setattr(self, k, new_value)
1241486
def update(self, iterable):
        """"""
        _lists = self._lists
        _maxes = self._maxes
        values = sorted(iterable)

        if _maxes:
            if len(values) * 4 >= self._len:
                values.extend(chain.from_iterable(_lists))
                values.sort()
                self._clear()
            else:
                _add = self.add
                for val in values:
                    _add(val)
                return

        _load = self._load
        _lists.extend(values[pos:(pos + _load)]
                      for pos in range(0, len(values), _load))
        _maxes.extend(sublist[-1] for sublist in _lists)
        self._len = len(values)
        del self._index[:]
983667
@SuppressWarnings("unchecked")
    private void fixdownMax(int k) {
        int c = 2 * k;
        while (c <= size) {
            int m = maxChildOrGrandchild(k);
            if (m > c + 1) { // grandchild
                if (((Comparable<? super K>) array[m]).compareTo(array[k]) <= 0) {
                    break;
                }
                K tmp = array[k];
                array[k] = array[m];
                array[m] = tmp;
                if (((Comparable<? super K>) array[m]).compareTo(array[m / 2]) < 0) {
                    tmp = array[m];
                    array[m] = array[m / 2];
                    array[m / 2] = tmp;
                }
                // go down
                k = m;
                c = 2 * k;
            } else { // child
                if (((Comparable<? super K>) array[m]).compareTo(array[k]) > 0) {
                    K tmp = array[k];
                    array[k] = array[m];
                    array[m] = tmp;
                }
                break;
            }
        }
    }
1285530
function replaceValue(obj, key, value) {
  if (!obj) return;
  if (obj instanceof Array) {
    for (const i in obj) {
      replaceValue(obj[i], key, value);
    }
  }
  if (obj[key]) obj[key] = value;
  if (typeof obj === 'object' && obj !== null) {
    const children = Object.keys(obj);
    for (let childIndex = 0; childIndex < children.length; childIndex++) {
      replaceValue(obj[children[childIndex]], key, value);
    }
  }
  return obj;
}
228337
def replace_values(in_m, out_m, map_from=(), map_to=()):
    '''
    
    '''
    for link in in_m.match():
        new_link = list(link)
        if map_from:
            if link[ORIGIN] in map_from: new_link[ORIGIN] = map_to[map_from.index(link[ORIGIN])]
        new_link[ATTRIBUTES] = link[ATTRIBUTES].copy()
        out_m.add(*new_link)
    return
909080
def _recurse_replace(obj, key, new_key, sub, remove):
    """"""
    if isinstance(obj, list):
        return [_recurse_replace(x, key, new_key, sub, remove) for x in obj]
    if isinstance(obj, dict):
        for k, v in list(obj.items()):
            if k == key and v in sub:
                obj[new_key] = sub[v]
                if remove:
                    del obj[key]
            else:
                obj[k] = _recurse_replace(v, key, new_key, sub, remove)
    return obj
588395
def replace(self, src: str) -> str:
        
        if not self.readied:
            self.ready()

        # Brackets + simple pre replacements:
        src = self._dict_replace(self.simple_pre, src)

        # Superscripts and subscripts + pre regexps:
        for regex, replace in self.regex_pre:
            src = regex.sub(replace, src)

        # Unary and binary operators:
        src = self._operators_replace(src)

        # Loop regexps:
        src_prev = src
        for i in range(self.max_iter):
            for regex, replace in self.loop_regexps:
                src = regex.sub(replace, src)
            if src_prev == src:
                break
            else:
                src_prev = src

        # Post regexps:
        for regex, replace in self.regex_post:
            src = regex.sub(replace, src)

        # Simple post replacements:
        src = self._dict_replace(self.simple_post, src)

        # Escape characters:
        src = self.escapes_regex.sub(r'\1', src)

        return src
62823
function replace (obj, key, val) {
  if (obj.hasOwnProperty(key)) obj[key] = val;
  return obj;
}