Iter recursively all tree items and restore expansion state
509642
def _restore_expansion_state(self):
        """"""

        def restore_tree_expansion(child_tree_iter, expansion_state):
            tree_item_path = self.history_tree_store.get_path(child_tree_iter)
            history_item = self.get_history_item_for_tree_iter(child_tree_iter)

            # restore expansion state if tree item path is valid and expansion state was not stored already
            if tree_item_path and history_item in expansion_state:
                if expansion_state[history_item]:
                    self.history_tree.expand_to_path(tree_item_path)

            for n in range(self.history_tree_store.iter_n_children(child_tree_iter)):
                child_iter = self.history_tree_store.iter_nth_child(child_tree_iter, n)
                restore_tree_expansion(child_iter, expansion_state)

        root_iter = self.history_tree_store.get_iter_first()
        if not root_iter:
            return
        state_machine = self.get_history_item_for_tree_iter(root_iter).state_reference.get_state_machine()
        if state_machine.state_machine_id not in self._expansion_state:
            return
        while root_iter:
            restore_tree_expansion(root_iter, self._expansion_state[state_machine.state_machine_id])
            root_iter = self.history_tree_store.iter_next(root_iter)
187406
def recursive_iter(enumerables):
    '''
    
    '''
    if not is_collection(enumerables) or isinstance(enumerables, (basestring, dict)):
        yield enumerables
    else:
        for elem in enumerables:
            for sub_elem in recursive_iter(elem):
                yield sub_elem
1139170
public static void expandAll(JTree tree, TreePath path, boolean expand)
	{
		TreeNode node = (TreeNode)path.getLastPathComponent();

		if (node.getChildCount() >= 0)
		{
			Enumeration<?> enumeration = node.children();
			while (enumeration.hasMoreElements())
			{
				TreeNode n = (TreeNode)enumeration.nextElement();
				TreePath p = path.pathByAddingChild(n);

				expandAll(tree, p, expand);
			}
		}

		if (expand)
		{
			tree.expandPath(path);
		}
		else
		{
			tree.collapsePath(path);
		}
	}
1343658
function () {
			var oModel = this._oDialog.getModel("view"),
				oTreeData = oModel.getProperty("/DebugModules")[0];

			this._treeHelper.recursiveSelect(oTreeData, false);
			this._updateTreeInfos();
		}
66992
def traverse(self):
        '''
        
        '''
        yield self, 0
        if self.name in self.expanded:
            for path in self.getpaths():
                for child, depth in path.traverse():
                    yield child, depth + 1
924105
protected void rebuildTree() {
    final int dim = root.getDimensionality();
    double t = estimateThreshold(root) / leaves;
    t *= t;
    // Never decrease the threshold.
    thresholdsq = t > thresholdsq ? t : thresholdsq;
    LOG.debug("New squared threshold: " + thresholdsq);

    LeafIterator iter = new LeafIterator(root); // Will keep the old root.
    assert (iter.valid());
    ClusteringFeature first = iter.get();

    leaves = 0;
    // Make a new root node:
    root = new TreeNode(dim, capacity);
    root.children[0] = first;
    root.addToStatistics(first);
    ++leaves;
    for(iter.advance(); iter.valid(); iter.advance()) {
      TreeNode other = insert(root, iter.get());
      // Handle root overflow:
      if(other != null) {
        TreeNode newnode = new TreeNode(dim, capacity);
        newnode.addToStatistics(newnode.children[0] = root);
        newnode.addToStatistics(newnode.children[1] = other);
        root = newnode;
      }
    }
  }
663705
def add_items_to_tree_iter(self, input_dict, treeiter, parent_dict_path=None):
        
        if parent_dict_path is None:
            parent_dict_path = []
        self.get_view_selection()
        for key, value in sorted(input_dict.items()):
            element_dict_path = copy.copy(parent_dict_path) + [key]
            if isinstance(value, dict):
                new_iter = self.tree_store.append(treeiter, [key, "", True, element_dict_path])
                self.add_items_to_tree_iter(value, new_iter, element_dict_path)
            else:
                self.tree_store.append(treeiter, [key, value, False, element_dict_path])
91994
def reload_tree_store_data(self):
        
        model, paths = self.tree_view.get_selection().get_selected_rows()

        self.tree_store.clear()
        self.add_items_to_tree_iter(self.model.state.semantic_data, None)
        self.tree_view.expand_all()

        try:
            for path in paths:
                self.tree_view.get_selection().select_path(path)
        except ValueError:
            pass
662278
function expandToItem(treeId,itemId) {
	var ul = document.getElementById(treeId);
	if (ul == null) { return false; }
	var ret = expandCollapseList(ul,nodeOpenClass,itemId);
	if (ret) {
		var o = document.getElementById(itemId);
		if (o.scrollIntoView) {
			o.scrollIntoView(false);
		}
	}
}
455246
def to_tree(instance, *children):
    

    # Yield representation of self
    yield unicode(instance)

    # Iterate trough each instance child collection
    for i, child in enumerate(children):
        lines = 0

        yield "|"
        yield "+---" + unicode(child)

        if i != len(children) - 1:
            a = "|"
        else:
            a = " "

        # Iterate trough all values of collection of child
        for j, item in enumerate(child.itervalues()):
            if j != len(child) - 1:
                b = "|"
            else:
                b = " "

            if j == 0:
                yield a + "   |"

            # Append prefix to each line
            for k, line in enumerate(item.to_tree()):
                lines += 1

                if k == 0:
                    yield a + "   +---" + line
                else:
                    yield a + "   " + b + "   " + line

        # Add extra space if required
        if len(children) > 1 and i == len(children) - 1 and lines > 1:
            yield a
768138
def update_all_nodes(self):
        
        item_model_controller = self.item_model_controller
        if item_model_controller:
            if self.__node_counts_dirty:
                for item in self.__mapping.values():
                    if "tree_node" in item.data:  # don't update the root node
                        tree_node = item.data["tree_node"]
                        item.data["display"] = self.__display_for_tree_node(tree_node)
                        item_model_controller.data_changed(item.row, item.parent.row, item.parent.id)
                self.__node_counts_dirty = False
1131210
def generic_visit(self, node, *args, **kwargs):
        """"""
        for node in node.iter_child_nodes():
            self.visit(node, *args, **kwargs)
223695
def items(self):
		

		L = []
		def aux(node, s):
			s = s + node.char
			if node.output is not nil:
				L.append((s, node.output))

			for child in node.children.values():
				if child is not node:
					aux(child, s)

		aux(self.root, '')
		return iter(L)
128699
private void traverse(GroovySourceAST t,List l,Iterator itr) {
         while (t != null) {
             // first visit of node
             if (l != null) {
                 l.add(new LineColumn(t.getLine(),t.getColumn()));
             }

             // second visit of node
             if (itr != null && itr.hasNext()) {
                 LineColumn lc = (LineColumn)itr.next();
                 if (t.getLineLast() == 0) {
                     int nextLine = lc.getLine();
                     int nextColumn = lc.getColumn();
                     if (nextLine < t.getLine() || (nextLine == t.getLine() && nextColumn < t.getColumn())) {
                         nextLine = t.getLine();
                         nextColumn = t.getColumn();
                     }
                     t.setLineLast(nextLine);
                     t.setColumnLast(nextColumn);
                     // This is a good point to call t.setSnippet(),
                     // but it bulks up the AST too much for production code.
                 }
             }

             GroovySourceAST child = (GroovySourceAST)t.getFirstChild();
             if (child != null) {
                 traverse(child,l,itr);
             }

             t = (GroovySourceAST)t.getNextSibling();
         }
    }
1010111
def extend(self, iter, parent=None):
        
        for item in iter:
            self.append(item, parent)
519042
def traversal(root):
    ''''''
    stack = [root]
    while len(stack) > 0:
        node = stack.pop()
        if hasattr(node,'children'):
            if node.children == set():
                try:
                    stack[-1].children.remove(node)
                except:
                    pass
                yield (node,stack)
            else:
                childnode = node.children.pop()
                stack += [node,childnode]
        else: 
            children = [x for x in ast.iter_child_nodes(node)]
            node.children = set(children)
            stack.append(node)
629774
def iter(self, root=None):
        
        if root is None:
            return iter(self._controls)
        return ((os.path.join(root, outdir), control)
                for outdir, control in self._controls)