For each node, we accumulate the rules that generated its children in a list.
552362
def add_action(self, node: Node) -> None:
        
        if node.expr.name and node.expr.name not in ['ws', 'wsp']:
            nonterminal = f'{node.expr.name} -> '

            if isinstance(node.expr, Literal):
                right_hand_side = f'["{node.text}"]'

            else:
                child_strings = []
                for child in node.__iter__():
                    if child.expr.name in ['ws', 'wsp']:
                        continue
                    if child.expr.name != '':
                        child_strings.append(child.expr.name)
                    else:
                        child_right_side_string = child.expr._as_rhs().lstrip("(").rstrip(")") # pylint: disable=protected-access
                        child_right_side_list = [tok for tok in
                                                 WHITESPACE_REGEX.split(child_right_side_string) if tok]
                        child_right_side_list = [tok.upper() if tok.upper() in
                                                 self.keywords_to_uppercase else tok
                                                 for tok in child_right_side_list]
                        child_strings.extend(child_right_side_list)
                right_hand_side = "[" + ", ".join(child_strings) + "]"
            rule = nonterminal + right_hand_side
            self.action_sequence = [rule] + self.action_sequence
447015
private List<String> collectRuleNames() {
        List<String> ruleNames = new ArrayList<>();
        for (Rule rule : rules) {
            ruleNames.add(rule.getName());
        }
        Collections.sort(ruleNames);
        return ruleNames;
    }
178976
def _to_tree(self, rule_node):
        """"""
        orig_rule = self.orig_rules[rule_node.rule.alias]
        children = []
        for child in rule_node.children:
            if isinstance(child, RuleNode):
                children.append(self._to_tree(child))
            else:
                assert isinstance(child.name, Token)
                children.append(child.name)
        t = Tree(orig_rule.origin, children)
        t.rule=orig_rule
        return t
411349
def leaves(self):
        ""
        for child in self.children:
            for x in child.leaves():
                yield x
        if not self.children:
            yield self
877468
def calculate_totals( self, children, local_children=None ):
        """"""
        for field,local_field in (('recursive','calls'),('cumulative','local')):
            values = []
            for child in children:
                if isinstance( child, PStatGroup ) or not self.LOCAL_ONLY:
                    values.append( getattr( child, field, 0 ) )
                elif isinstance( child, PStatRow ) and self.LOCAL_ONLY:
                    values.append( getattr( child, local_field, 0 ) )
            value = sum( values )
            setattr( self, field, value )
        if self.recursive:
            self.cumulativePer = self.cumulative/float(self.recursive)
        else:
            self.recursive = 0
        if local_children:
            for field in ('local','calls'):
                value = sum([ getattr( child, field, 0 ) for child in children] )
                setattr( self, field, value )
            if self.calls:
                self.localPer = self.local / self.calls
        else:
            self.local = 0
            self.calls = 0
            self.localPer = 0
627373
private List<ExpandableWrapper<P, C>> generateFlattenedParentChildList(List<P> parentList) {
        List<ExpandableWrapper<P, C>> flatItemList = new ArrayList<>();

        int parentCount = parentList.size();
        for (int i = 0; i < parentCount; i++) {
            P parent = parentList.get(i);
            generateParentWrapper(flatItemList, parent, parent.isInitiallyExpanded());
        }

        return flatItemList;
    }
833396
def each_child_node_of(o)
      if array_like? o and not record_like? o
        if o.respond_to? :to_hash
          o.each {|k, v| yield Mapping.new(k, v) }
        else
          o.each {|_| yield _ }
        end
      end
    end
142151
def children_sum( self, children,node ):
        """"""
        return sum( [self.value(value,node) for value in children] )
1306585
def _children(self):
        """"""
        if self.declarations:
            yield self.declarations
        if isinstance(self.condition, CodeExpression):
            yield self.condition
        if self.increment:
            yield self.increment
        for codeobj in self.body._children():
            yield codeobj
1028795
private function generateAllRules(): void
    {
        for ($k = 2; isset($this->large[$k]); ++$k) {
            foreach ($this->large[$k] as $frequent) {
                $this->generateRules($frequent);
            }
        }
    }
345509
def recursive_children(self):
        

        for child in self.children:
            yield child

            for recursive_child in child.recursive_children:
                yield recursive_child
1101270
def append_rules(self, an_iterable):
        """"""
        self.rules.extend(
            TransformRule(*x, config=self.config) for x in an_iterable
        )
699628
private static <T extends HierarchyEntity<T, ?>> void loadChildren(T node, Set<T> children) {
    if (null == node.getChildren()) { return; }
    for (T one : node.getChildren()) {
      children.add(one);
      loadChildren(one, children);
    }
  }
1091693
function processRule(node, item, list) {
    var selectors = node.prelude.children;
    var declarations = node.block.children;
    var nodeCompareMarker = selectors.first().compareMarker;
    var skippedCompareMarkers = {};

    list.nextUntil(item.next, function(next, nextItem) {
        // skip non-ruleset node if safe
        if (next.type !== 'Rule') {
            return utils.unsafeToSkipNode.call(selectors, next);
        }

        if (node.pseudoSignature !== next.pseudoSignature) {
            return true;
        }

        var nextFirstSelector = next.prelude.children.head;
        var nextDeclarations = next.block.children;
        var nextCompareMarker = nextFirstSelector.data.compareMarker;

        // if next ruleset has same marked as one of skipped then stop joining
        if (nextCompareMarker in skippedCompareMarkers) {
            return true;
        }

        // try to join by selectors
        if (selectors.head === selectors.tail) {
            if (selectors.first().id === nextFirstSelector.data.id) {
                declarations.appendList(nextDeclarations);
                list.remove(nextItem);
                return;
            }
        }

        // try to join by properties
        if (utils.isEqualDeclarations(declarations, nextDeclarations)) {
            var nextStr = nextFirstSelector.data.id;

            selectors.some(function(data, item) {
                var curStr = data.id;

                if (nextStr < curStr) {
                    selectors.insert(nextFirstSelector, item);
                    return true;
                }

                if (!item.next) {
                    selectors.insert(nextFirstSelector);
                    return true;
                }
            });

            list.remove(nextItem);
            return;
        }

        // go to next ruleset if current one can be skipped (has no equal specificity nor element selector)
        if (nextCompareMarker === nodeCompareMarker) {
            return true;
        }

        skippedCompareMarkers[nextCompareMarker] = true;
    });
}
1341311
protected List<R> visitChildren(ParentNode<? extends N> node) {
    List<R> results = new ArrayList<>(node.numChildren());
    for (N child : node.getChildren()) {
      results.add(visit(child));
    }
    return results;
  }
346200
def _setChildren(self):
		
		if self.index + 1 < len(self.gametree):
			self.children = [self.gametree[self.index+1]]
		else:
			self.children = map(lambda list: list[0], self.gametree.variations)
526677
public void addChildren(List<? extends Tree> kids) {
		for (int i = 0; i < kids.size(); i++) {
			Tree t = kids.get(i);
			addChild(t);
		}
	}