Finds the number of times a simple name is referenced within the node tree.
498444
static int getNameReferenceCount(Node node, String name) {
    return getCount(node, new MatchNameNode(name), Predicates.alwaysTrue());
  }
933331
static int getNodeTypeReferenceCount(
      Node node, Token type, Predicate<Node> traverseChildrenPred) {
    return getCount(node, new MatchNodeType(type), traverseChildrenPred);
  }
505060
def nodes(self, tree):
        
        # Run the match against the tree
        if self.frequency == 'per_session':
            nodes = []
            for subject in tree.subjects:
                for sess in subject.sessions:
                    nodes.append(sess)
        elif self.frequency == 'per_subject':
            nodes = tree.subjects
        elif self.frequency == 'per_visit':
            nodes = tree.visits
        elif self.frequency == 'per_study':
            nodes = [tree]
        else:
            assert False, "Unrecognised frequency '{}'".format(
                self.frequency)
        return nodes
1147411
def rowCount(self, parent=QModelIndex()):
        

        if not parent.isValid():
            parent_node = self.__root_node
        else:
            parent_node = parent.internalPointer()
        return parent_node.children_count()
678696
def in_tree(self, name):
        
        """
        if self._validate_node_name(name):
            raise RuntimeError("Argument `name` is not valid")
        return name in self._db
378185
def get_unique_named_object(root, name):
    
    a = get_children(lambda x: hasattr(x, 'name') and x.name == name, root)
    assert len(a) == 1
    return a[0]
265603
def name(self, node, children):
        ''
        return self.env.get(node.text.strip(), -1)
995438
function() {
        for (var i = 0, count = 0;i< this.children.length;i++) {
            count += this.children[i].getNodeCount();
        }
        return count + 1;
    }
146557
def num_leaves(tree):
    """"""
    if tree.is_leaf:
        return 1
    else:
        return num_leaves(tree.left_child) + num_leaves(tree.right_child)
1248017
private void findReferences(ImmutableBean root) {
        // handle root bean
        classes.put(root.getClass(), classInfoFromMetaBean(root.metaBean(), root.getClass()));
        classSerializationCount.put(root.getClass(), 1);

        // recursively check object graph
        Map<Object, Integer> objects = new LinkedHashMap<>();
        findReferencesBean(root, root.getClass(), objects, null);

        // build up the list of references, but only for those instances that are repeated
        List<Map.Entry<Object, Integer>> refEntries = objects.entrySet().stream()
                .sorted(reverseOrder(comparingInt(Map.Entry::getValue)))
                .filter(entry -> entry.getValue() > 1)
                .collect(toList());
        for (Map.Entry<Object, Integer> entry : refEntries) {
            Object value = entry.getKey();
            Class<?> realType = value.getClass();

            // simple types do not need references
            if (realType != Integer.class &&
                    realType != Double.class &&
                    realType != Float.class &&
                    realType != Boolean.class &&
                    realType != Long.class &&
                    realType != Short.class &&
                    realType != Byte.class &&
                    realType != byte[].class) {

                refs.put(value, new Ref(false, refs.size()));
            }
        }
        
        // reorder classes so the most repeated serialized names have the lowest number (hence the shortest extension)
        this.classInfoList.addAll(classSerializationCount.entrySet().stream()
                .sorted(reverseOrder(comparingInt(Map.Entry::getValue)))
                .map(entry -> classes.get(entry.getKey()))
                .collect(toList()));

        // adjust the position in the ClassInfo instance
        for (int position = 0; position < classInfoList.size(); position++) {
            ClassInfo classInfo = classInfoList.get(position);
            classInfo.position = position;
        }
    }
700834
def visit_num(self, node, parent):
        """"""
        return nodes.Const(
            node.n,
            getattr(node, "lineno", None),
            getattr(node, "col_offset", None),
            parent,
        )
1103539
private NodeList getByName(String name) {
        NodeList answer = new NodeList();
        for (Object child : children()) {
            if (child instanceof Node) {
                Node childNode = (Node) child;
                Object childNodeName = childNode.name();
                if (childNodeName instanceof QName) {
                    QName qn = (QName) childNodeName;
                    if (qn.matches(name)) {
                        answer.add(childNode);
                    }
                } else if (name.equals(childNodeName)) {
                    answer.add(childNode);
                }
            }
        }
        return answer;
    }
1152418
private int countAttributes(NamedNodeMap attributesR) {
        int cntAttributes = 0;

        for (int i = 0; i < attributesR.getLength(); i++) {
            if (!attributesR.item(i).getNodeName().startsWith(XMLConstants.XMLNS_ATTRIBUTE)) {
                cntAttributes++;
            }
        }

        return cntAttributes;
    }
720441
def _get_simple_assignments(tree):
    """"""
    result = {}
    for node in ast.walk(tree):
        if isinstance(node, ast.Assign):
            for target in node.targets:
                if isinstance(target, ast.Name):
                    result[target.id] = node.value
    return result
409434
def collect_values_with_count_subtree(flag=nil)
		values = collect_values_with_count
		all_children_deep(flag).each do |c|
			c.collect_values_with_count.each do |k,v|
				values[k]+=v
			end
		end
		values
	end
128115
private static void getLeafNodes(
        TreeModel treeModel, Object node, Collection<Object> leafNodes)
    {
        if (node == null)
        {
            return;
        }
        int childCount = treeModel.getChildCount(node);
        if (childCount == 0)
        {
            leafNodes.add(node);
        }
        else
        {
            for (int i = 0; i < childCount; i++)
            {
                Object child = treeModel.getChild(node, i);
                getLeafNodes(treeModel, child, leafNodes);
            }
        }
    }
17403
def numberofnetworks(self):
        """"""
        sels1 = selectiontools.Selections()
        sels2 = selectiontools.Selections()
        complete = selectiontools.Selection('complete',
                                            self.nodes, self.elements)
        for node in self.endnodes:
            sel = complete.copy(node.name).select_upstream(node)
            sels1 += sel
            sels2 += sel.copy(node.name)
        for sel1 in sels1:
            for sel2 in sels2:
                if sel1.name != sel2.name:
                    sel1 -= sel2
        for name in list(sels1.names):
            if not sels1[name].elements:
                del sels1[name]
        return sels1