* recursive - we need to cover deep nested items.
778165
function findValueOfChildren(child, fieldToBeValidated){
	if (!child.props.hasOwnProperty(fieldToBeValidated)) {
		if (child.props.children) {
			if (child.props.children.length) {
				let arr = child.props.children.map((item) => {
					return findValueOfChildren(item, fieldToBeValidated);
				});

				return findValueInArray(arr);
			}
			else {
				return findValueOfChildren(child.props.children, fieldToBeValidated);
			}
		}
	}
	else {
		return child.props;
	}
}
201969
def is_recursive(self, child_item):
        """"""
        ancestor = child_item.parent()
        # FIXME: indexes to data should be defined by a dictionary on init
        while ancestor:
            if (child_item.data(0, Qt.DisplayRole
                                ) == ancestor.data(0, Qt.DisplayRole) and
                child_item.data(7, Qt.DisplayRole
                                ) == ancestor.data(7, Qt.DisplayRole)):
                return True
            else:
                ancestor = ancestor.parent()
        return False
919328
def ReplaceChild(self, key, item):
        '''
        
        '''
        if key in self.GetChildrenIndexes():
            node = self.GetChild(key)
            children = node.GetChildrenIndexes()
            child_nodes = [(i, node.GetChild(i)) for i in children]
            self.children[key] = item
            [self.children[key].AddChild(kid[1], kid[0])
             for kid in child_nodes]
1284879
def get_roles_in_node(node, recursive=False, depth=0):
    
    LIMIT = 5
    roles = []
    for elem in node.get('run_list', []):
        if elem.startswith("role"):
            role = elem.split('[')[1].split(']')[0]
            if role not in roles:
                roles.append(role)
                if recursive and depth <= LIMIT:
                    roles.extend(get_roles_in_node(_get_role(role),
                                                   recursive=True,
                                                   depth=depth + 1))
    return list(set(roles))
1222372
def interior_nesting(cls, elem1, xpath, namespaces=None):
        """"""
        for elem2 in elem1.xpath(xpath, namespaces=namespaces):
            child_elem1 = etree.Element(elem1.tag)
            for k in elem1.attrib:
                child_elem1.set(k, elem1.get(k))
            child_elem1.text, elem2.text = elem2.text, ''
            for ch in elem2.getchildren():
                child_elem1.append(ch)
            elem2.insert(0, child_elem1)
        XML.replace_with_contents(elem1)
794412
def children(self, recursive=False):
        
        for i in xrange(self.childCount()):
            child = self.child(i)
            yield child
            
            if recursive:
                for subchild in child.children(recursive=True):
                    yield subchild
1219250
function(state, datasetId, items, matchFound, nestingLevel, stopExpandingParents) {
            // initialize whatever wasn't passed to a default value
            datasetId = datasetId || 'default';
            items = items || concealed.items[datasetId];
            matchFound = matchFound || false;
            nestingLevel = nestingLevel || 0;

            for (var i = items.length; --i >= 0;) {
                if (!!items[i].items && !!items[i].items.length) {
                    // matchFound here would mean that a match was found in a descendant
                    matchFound = visible.setActive(state, datasetId, items[i].items, matchFound, nestingLevel + 1, stopExpandingParents);
                    if (matchFound && !stopExpandingParents) {
                        items[i].expanded = true;
                        if (nestingLevel === 0) {
                            stopExpandingParents = true;
                        }
                    }
                } else {
                    if (matchFound) {
                        // matchFound here would mean either a sibling node or some other node was already matched
                        // so we want to skip the comparison to save time
                        items[i].isActive = false;
                    } else {
                        if (!!items[i].stateName && items[i].stateName === state) {
                            // if the item's state is the one being searched for then set the item to active and flip the matched flag
                            items[i].isActive = true;
                            matchFound = true;
                            stopExpandingParents = true;
                        } else {
                            items[i].isActive = false;
                        }
                    }
                }
            }

            return matchFound;
        }
668977
function recurvsiveFlatten(name, obj, arr, depth){

  var type;

  // "items" property flags a nested object or array, so it needs special treatment
  if (obj.hasOwnProperty('items')) {

    type = obj.items.type;

    // Keep track of what type of array this is (if it is an array type)
    if (obj.type === 'array') {
      type = lodash.capitalize(type) + '[]';
    }

    // Add the object or array to the flattened property array
    arr.push({name: name, type: type, description: obj.description || '', depth: depth});

    // Loop thru the item's properties and execute the recursive function
    lodash.forIn(obj.items.properties, function (val, key) {
      recurvsiveFlatten(key, val, arr, depth + 1);
    });

  } else if (obj.hasOwnProperty('properties')) {

    // Add the object to the flattened property array
    arr.push({name: name, type: 'Object', description: obj.description || '', depth: depth});

    // Execute the recursive function on all properties
    lodash.forIn(obj.properties, function(val, key){
      recurvsiveFlatten(key, val, arr, depth + 1);
    });
  } else {

    // Add the property to the flattened property array
    arr.push({name: name, type: obj.type, description: obj.description, depth: depth});
  }

}
788905
public Function<String, Map<String, Double>> categorizationTree(Map<String, List<String>> categories, int depth) {
    return categorizationTree(categories, depth, "");
  }
738625
function(tree, n, m) {
    return tree[n].fc < tree[m].fc ||
      (tree[n].fc == tree[m].fc && zip_depth[n] <= zip_depth[m]);
}
209086
def stack(me, children)
      children = children.map{|c| c.is_a?(::Layers::LayerBase) ? c.to_node([]) : c}
      me.to_node(children)
    end
637578
def expand_nested(self, cats):
        """"""
        down = '│'
        right = '└──'

        def get_children(parent):
            return [e() for e in parent._entries.values() if e._container == 'catalog']

        if len(cats) == 0:
            return

        cat = cats[0]
        old = list(self.options.items())
        name = next(k for k, v in old if v == cat)
        index = next(i for i, (k, v) in enumerate(old) if v == cat)
        if right in name:
            prefix = f'{name.split(right)[0]}{down} {right}'
        else:
            prefix = right

        children = get_children(cat)
        for i, child in enumerate(children):
            old.insert(index+i+1, (f'{prefix} {child.name}', child))
        self.widget.options = dict(old)
16094
function resolve_recursion(){
		$copy = $this->children;
		foreach( $copy as $i => $Child ){
			// recurse.
			$Child->resolve_recursion();
			// if child node is same symbol as self, replace with it's contents
			if( $Child->t === $this->t ){
				$this->splice( $Child, $Child->children );
			}
		}
	}
752214
protected boolean nestedMatch(Matcher<?> matcher, Object item, Description mismatch) {
        return Nested.matches(this, matcher, item, mismatch);
    }
1097588
def print_children_recursively(all_items, for_item, level):
    
    children = [child for child in all_items if child.parentid == for_item.id]
    for child in children:
        #message = f"{for_item.name}({for_item.id}) is a parent to {child.name}({child.id})"
        indent = " " * level * 2
        id_col = f"{indent} {child.id}"
        print_row(id_col, child.name, f"{child.allocation:,.2f}", level)

        # Process children.
        print_children_recursively(all_items, child, level+1)
967091
def nested_insert(self, item_list):
        
        if len(item_list) == 1:
            self[item_list[0]] = LIVVDict()
        elif len(item_list) > 1:
            if item_list[0] not in self:
                self[item_list[0]] = LIVVDict()
            self[item_list[0]].nested_insert(item_list[1:])
1077367
def get_item_children(item):
    """"""
    children = [item.child(index) for index in range(item.childCount())]
    for child in children[:]:
        others = get_item_children(child)
        if others is not None:
            children += others
    return sorted(children, key=lambda child: child.line)