recursively make sure that no dictionaries inside node contain empty children lists
770911
def noEmptyNests(node): 
    ''' '''
    if type(node)==list:
        for i in node:
            noEmptyNests(i)
    if type(node)==dict:
        for i in node.values():
            noEmptyNests(i)
        if node["children"] == []:
            node.pop("children")
    return node
836485
public void removeEmptySubtrees(CmsTreeNode<I_CmsContextMenuItem> root) {

        List<CmsTreeNode<I_CmsContextMenuItem>> children = root.getChildren();
        if ((root.getData() != null) && root.getData().isLeafItem()) {
            children.clear();
        } else {
            Iterator<CmsTreeNode<I_CmsContextMenuItem>> iter = children.iterator();
            while (iter.hasNext()) {
                CmsTreeNode<I_CmsContextMenuItem> node = iter.next();
                removeEmptySubtrees(node);
                if ((node.getData() != null) && !node.getData().isLeafItem() && (node.getChildren().size() == 0)) {
                    iter.remove();
                }
            }
        }
    }
1036016
function(node, callback, depth) {
			if (this.isSkipped(node)) {
				return;
			}

			var childNode,
				childNodes = node && node.childNodes || [];

			depth = (depth || 1);

			for (var n = 0, len = childNodes.length; n < len; n++) {
				childNode = childNodes[n];

				// callback can return false to stop recursive
				if (callback(childNode, depth) !== false) {
					this.walk(childNode, callback, depth + 1);
				}
			}
		}
1085729
def _is_child_wikicode(self, obj, recursive=True):
        """"""
        def deref(nodes):
            if isinstance(nodes, _ListProxy):
                return nodes._parent  # pylint: disable=protected-access
            return nodes

        target = deref(obj.nodes)
        if target is deref(self.nodes):
            return True
        if recursive:
            todo = [self]
            while todo:
                code = todo.pop()
                if target is deref(code.nodes):
                    return True
                for node in code.nodes:
                    todo += list(node.__children__())
        return False
780508
def el_is_empty(el):
    """"""
    if len(el) == 1 and not isinstance(el[0], (list, tuple)):
        return True
    subels_are_empty = []
    for subel in el:
        if isinstance(subel, (list, tuple)):
            subels_are_empty.append(el_is_empty(subel))
        else:
            subels_are_empty.append(not bool(subel))
    return all(subels_are_empty)
985149
def isempty(self, content=True):
        
        nochildren = not self.children
        notext = self.text is None
        nocontent = nochildren and notext
        if content:
            return nocontent
        noattrs = not len(self.attributes)
        return nocontent and noattrs
38928
def process_children(self, node, elem, module, path, omit=[]):
        """"""
        for ch in node.i_children:
            if ch not in omit and (ch.i_config or self.doctype == "data"):
                self.node_handler.get(ch.keyword, self.ignore)(
                    ch, elem, module, path)
324289
function cleanAst(node) {
  var copy = {};

  Object.keys(node).forEach(function (key, i) {
    if (key !== 'parent' && key !== 'prev' && key !== 'next' && key !== '_items') {
      copy[key] = node[key];
    }
  });

  node = copy;

  if (node.nodes) {
    var children = node.nodes;
    node.nodes = [];
    children.forEach(function (childNode, i) {
      if (childNode.type) {
        node.nodes.push(cleanAst(childNode));
      } else {
        node.nodes.push(childNode);
      }
    });
  }

  return node;
}
675695
def _drop_empty_props(self, item):
        
        if isinstance(item, list):
            return [self._drop_empty_props(i) for i in item]
        if isinstance(item, dict):
            return {
                k: self._drop_empty_props(v)
                for k, v in item.items() if v != ''
            }
        return item
793036
function(str, pos) {
    var T = this, k, child;
    if (str.length == 0) {
      if (pos === undefined) {
        return T.getAllWords(str);
      } else {
        return [];
      }
    }
    if (pos === undefined) {
      pos = 0;
    }
    k = str[pos];
    child = T.children[k];
    if (child === undefined) {
      //node doesn't exist
      return [];
    }
    if (pos === str.length - 1) {
      return child.getAllWords(str);
    }
    return child.autoComplete(str, pos + 1);
  }
864912
def empty_content?(element)
        text = +""
        child_nodes = element.child_nodes
        (0...child_nodes.length).each do |i|
          item = child_nodes.item(i)
          if item.node_type == Node.TEXT_NODE
            text << item.get_data.strip
          end
        end
        text.strip.length == 0
      end
114173
def strip_tree(node,
               # Runtime optimization
               iter_node=iter_node, special=ast.AST,
               list=list, isinstance=isinstance, type=type, len=len):
    
    stripped = set()

    def strip(node, indent):
        unknown = set()
        leaf = True
        for subnode, _ in iter_node(node, unknown=unknown):
            leaf = False
            strip(subnode, indent + '    ')
        if leaf:
            if isinstance(node, special):
                unknown = set(vars(node))
        stripped.update(unknown)
        for name in unknown:
            delattr(node, name)
        if hasattr(node, 'ctx'):
            delattr(node, 'ctx')
            if 'ctx' in node._fields:
                mylist = list(node._fields)
                mylist.remove('ctx')
                node._fields = mylist
    strip(node, '')
    return stripped
773868
function removeEmptyContainers() {
  var elementWasRemoved = true;
  do {
    elementWasRemoved = false;
    _($('defs, metadata, g')).each(function(node) {
      if(!node.children.length) {
        $(node).remove();
        elementWasRemoved = true;
      }
    });
  } while(elementWasRemoved);
}
940705
function removeChildInternals (withoutInternal) {
  return _.chain(withoutInternal)
    .map((item, key) => {
      const withoutInternal = removeInternalValues(item)
      if (withoutInternal !== undefined && withoutInternal !== item) {
        return [key, withoutInternal]
      }
    })
    .filter()
    .fromPairs()
    .value()
}
153656
def _clean_xmldict_single_dic(self, dictionary):
        
        for k, v in dictionary.items():
            if v is None:
                dictionary[k] = ''
23023
function arrayTreeFilter (data, filterFn, options) {
    options = options || {}
    options.childrenKeyName = options.childrenKeyName || 'children'
    let children = data || []
    const result = []
    let level = 0
    do {
        const foundItem = children.filter(function (item) {
            return filterFn(item, level)
        })[0]
        if (!foundItem) {
            break
        }
        result.push(foundItem)
        children = foundItem[options.childrenKeyName] || []
        level += 1
    } while (children.length > 0)
    return result
}
586676
def is_empty_dir(self):
        
        if self.mets_div_type == "Directory":
            children = self._children
            if children:
                if all(child.is_empty_dir for child in children):
                    return True
                else:
                    return False
            else:
                return True
        else:
            return False