Recursively constructs a tree of completions.
485933
static CompletableFuture<Void> andTree(CompletableFuture<?>[] cfs, int lo, int hi) {
    CompletableFuture<Void> d = new CompletableFuture<Void>();
    if (lo > hi) // empty
      d.result = NIL;
    else {
      CompletableFuture<?> a, b;
      Object r, s, z;
      Throwable x;
      int mid = (lo + hi) >>> 1;
      if ((a = (lo == mid ? cfs[lo] : andTree(cfs, lo, mid))) == null
          || (b = (lo == hi ? a : (hi == mid + 1) ? cfs[hi] : andTree(cfs, mid + 1, hi))) == null)
        throw new NullPointerException();
      if ((r = a.result) == null || (s = b.result) == null)
        a.bipush(b, new BiRelay(d, a, b));
      else if ((r instanceof AltResult && (x = ((AltResult) (z = r)).ex) != null)
          || (s instanceof AltResult && (x = ((AltResult) (z = s)).ex) != null))
        d.result = encodeThrowable(x, z);
      else
        d.result = NIL;
    }
    return d;
  }
605031
def tree_structures_for(self, prefix, current_oid, parent_oids, prefixes):
        
        if prefix and prefixes and prefix not in prefixes:
            return empty, empty

        parent_files = set()
        for oid in parent_oids:
            parent_files.update(self.entries_in_tree_oid(prefix, oid))

        current_files = self.entries_in_tree_oid(prefix, current_oid)
        return (current_files, parent_files), (current_files - parent_files)
130131
def build_tree(X, y, criterion, max_depth, current_depth=1):
    

    # check for max_depth accomplished
    if max_depth >= 0 and current_depth >= max_depth:
        return Leaf(y)

    # check for 0 gain
    gain, question = find_best_question(X, y, criterion)
    if gain == 0:
        return Leaf(y)

    # split
    true_X, false_X, true_y, false_y = split(X, y, question)

    # Build the `true` branch of the tree recursively
    true_branch = build_tree(
        true_X, true_y,
        criterion,
        max_depth,
        current_depth=current_depth+1
    )
    
    # Build the `false` branch of the tree recursively
    false_branch = build_tree(
        false_X, false_y,
        criterion,
        max_depth,
        current_depth=current_depth+1
    )

    # returning the root of the tree/subtree
    return Node(
        question=question,
        true_branch=true_branch,
        false_branch=false_branch
    )
836673
def _build_kth_tree(self):
        """"""
        neg_tau = -1.0 * abs(self.tau_matrix)
        edges = self.previous_tree.edges
        visited = set([0])
        unvisited = set(range(self.n_nodes))

        while len(visited) != self.n_nodes:
            adj_set = set()
            for x in visited:
                for k in range(self.n_nodes):
                    # check if (x,k) is a valid edge in the vine
                    if k not in visited and k != x and self._check_contraint(edges[x], edges[k]):
                        adj_set.add((x, k))

            # find edge with maximum tau
            if len(adj_set) == 0:
                visited.add(list(unvisited)[0])
                continue

            pairs = sorted(adj_set, key=lambda e: neg_tau[e[0]][e[1]])[0]
            left_parent, right_parent = Edge.sort_edge([edges[pairs[0]], edges[pairs[1]]])

            new_edge = Edge.get_child_edge(len(visited) - 1, left_parent, right_parent)
            new_edge.tau = self.tau_matrix[pairs[0], pairs[1]]
            self.edges.append(new_edge)

            visited.add(pairs[1])
            unvisited.remove(pairs[1])
459501
def __generate_tree(self, top, src, resources, models, ctrls, views, utils):
        """"""
        res = self.__mkdir(top)
        for fn in (src, models, ctrls, views, utils): res = self.__mkpkg(fn) or res
        res = self.__mkdir(resources) or res
        res = self.__mkdir(os.path.join(resources, "ui", "builder")) or res
        res = self.__mkdir(os.path.join(resources, "ui", "styles")) or res
        res = self.__mkdir(os.path.join(resources, "external")) or res
        return res
1276060
def _build_first_tree(self):
        """"""
        tau_sorted = self._sort_tau_by_y(0)
        for itr in range(self.n_nodes - 1):
            ind = int(tau_sorted[itr, 0])
            name, theta = Bivariate.select_copula(self.u_matrix[:, (0, ind)])

            new_edge = Edge(itr, 0, ind, name, theta)
            new_edge.tau = self.tau_matrix[0, ind]
            self.edges.append(new_edge)
61918
def show_completion_list(self, completions, completion_text=""):
        """"""
        if not completions:
            return
        if not isinstance(completions[0], tuple):
            completions = [(c, '') for c in completions]
        if len(completions) == 1 and completions[0][0] == completion_text:
            return
        self.completion_text = completion_text
        # Sorting completion list (entries starting with underscore are
        # put at the end of the list):
        underscore = set([(comp, t) for (comp, t) in completions
                          if comp.startswith('_')])

        completions = sorted(set(completions) - underscore,
                             key=lambda x: str_lower(x[0]))
        completions += sorted(underscore, key=lambda x: str_lower(x[0]))
        self.show_completion_widget(completions)
310227
def _build_tree(self):
        
        if not self.nn_ready:
            self.kdtree   = scipy.spatial.cKDTree(self.data)
            self.nn_ready = True
1333888
def _recursive_matches(self, nodes, count):
        """"""
        assert self.content is not None
        if count >= self.min:
            yield 0, {}
        if count < self.max:
            for alt in self.content:
                for c0, r0 in generate_matches(alt, nodes):
                    for c1, r1 in self._recursive_matches(nodes[c0:], count+1):
                        r = {}
                        r.update(r0)
                        r.update(r1)
                        yield c0 + c1, r
654280
def walk_tree(root):
    """"""
    yield root

    for child in root.children:
        for el in walk_tree(child):
            yield el
403237
async function buildDirectDependentTree() {
  const dependents = new Map();

  for (const packageName of await _list()) {
    dependents.set(packageName, new Set());
  }

  for (const packageName of await _list()) {
    for (const dep of tree.get(packageName)) {
      dependents.get(dep).add(packageName);
    }
  }

  return dependents;
}
102090
function buildTree(directory, depth) {
  const files = fs.readdirSync(directory);
  const max_index = files.length - 1
  const color = chalk[colors[depth % colors.length]]

  for (let i = 0; i <= max_index; i++) {
    const file = files[i]
    depths[depth] = max_index - i
    const fullPath = path.resolve(directory, file)
    const prefix = buildPrefix(depth, i === max_index, directory)
    const stats = fs.statSync(fullPath)
    const isDirectory = stats.isDirectory()
    const size = prettybytes(stats.size)

    if (isDirectory) {
      directoryCount++
    } else {
      fileCount++
      totalFileSize += stats.size
    }

    if (!isDirectory && !shouldBeIncluded(file)) {
      return
    }

    const filename = useColors ? color(file) : file
    output += prefix + filename + (!isDirectory && showSize ? ` (${size})` : '') + '\n';
    if (isDirectory && (depth + 1 < maxDepth)) {
      buildTree(path.resolve(directory, file), depth + 1)
    }
    --depths[depth]
  }
}
1169459
def _complete_type_chain(self, symbol, fullsymbol):
        """"""
        target, targmod = self._get_chain_parent_symbol(symbol, fullsymbol)
        if target is None:
            return {}

        result = {}
        #We might know what kind of symbol to limit the completion by depending on whether
        #it was preceded by a "call " for example. Check the context's el_call
        if symbol != "":
            if self.context.el_call != "sub":
                for mkey in target.members:
                    if self._symbol_in(symbol, mkey):
                        result[mkey] = target.members[mkey]

            for ekey in target.executables:
                if (self._symbol_in(symbol, ekey)):
                    if self.context.el_call == "sub":
                        if (isinstance(target.executables[ekey], Subroutine)):
                            result[ekey] = target.executables[ekey]
                    else:
                        if (isinstance(target.executables[ekey], Function)):
                            result[ekey] = target.executables[ekey]
        else:
            if self.context.el_call != "sub":
                result.update(target.members)
                subdict = {k: target.executables[k] for k in target.executables
                           if isinstance(target.executables[k].target, Function)}
                result.update(subdict)
            else:
                subdict = {k: target.executables[k] for k in target.executables
                           if isinstance(target.executables[k].target, Subroutine)}
                result.update(subdict)

        return result
219857
private StringTreeNode buildOrgHierarchyTree(final Object[] data) {
		StringTreeNode childNode = new StringTreeNode((String) data[0]);

		if (data.length > 1) {
			for (int i = 1; i < data.length; i++) {
				childNode.add(buildOrgHierarchyTree((Object[]) data[i]));
			}
		}

		return childNode;
	}
541272
private void recursiveCollapseAreas(AreaImpl root)
    {
        if (canCollapse(root))
        {
            //System.out.println("Collapsing: " + root);
            recursiveCollapseSubtree(root, root);
            root.removeAllChildren();
        }
        else
        {
            for (int i = 0; i < root.getChildCount(); i++)
                recursiveCollapseAreas((AreaImpl) root.getChildAt(i));
        }
    }
    
    private boolean canCollapse(AreaImpl area)
    {
        return (area.getChildCount() == 1 && area.getChildAt(0).isLeaf());
    }

    private void recursiveCollapseSubtree(AreaImpl src, AreaImpl dest)
    {
        for (int i = 0; i < src.getChildCount(); i++)
        {
            AreaImpl child = (AreaImpl) src.getChildAt(i);
            recursiveCollapseSubtree(child, dest);
            dest.joinChild(child);
        }
    }

    
}
1117023
public void buildCategoryTree(List<CmsCategoryTreeEntry> treeEntries, Collection<String> selectedCategories) {

        m_valuesSet = 0;
        m_allSidePath.clear();
        m_categories.removeFromParent();
        m_categories.clear();

        if ((treeEntries != null) && !treeEntries.isEmpty()) {
            // add the first level and children
            for (CmsCategoryTreeEntry category : treeEntries) {
                // set the category tree item and add to list
                CmsTreeItem treeItem;
                boolean hasSelectedChildren = hasSelectedChildren(category.getChildren(), selectedCategories);
                if (!category.getPath().isEmpty() || hasSelectedChildren) {
                    if (m_selectParent || !hasSelectedChildren) {
                        treeItem = buildTreeItem(category, selectedCategories, false);
                        if (treeItem.isOpen()) {
                            m_allSidePath.add(category.getSitePath());
                        }
                    } else {
                        treeItem = buildTreeItem(category, selectedCategories, true);
                    }
                    if (treeItem.isOpen()) {
                        m_singleSidePath = category.getSitePath();

                        m_valuesSet++;
                        addChildren(treeItem, category.getChildren(), selectedCategories);
                    }
                }
            }
        }
        m_scrollPanel.add(m_categories);
        m_scrollPanel.onResizeDescendant();

    }
1265140
function _buildDependencyTreeOf(node) {
		var requireStatements = getRequireStatements(getCode(node.path))
		if (requireStatements.length == 0) {
			return leaves.push(node)
		}
		each(requireStatements, function(requireStatement) {
			var childNode = []
			childNode.path = resolve.requireStatement(requireStatement, node.path)
			childNode.parent = node
			node.push(childNode)
			_buildDependencyTreeOf(childNode)
		})
		node.waitingForNumChildren = node.length
	}