Return the root of a balanced binary search tree populated with the
        values in iterable *iseq*.
354206
def from_ordered_sequence(cls, iseq):
        
        seq = list(iseq)
        # optimize for usually all fits by making longest first
        bst = cls(seq.pop())
        bst._insert_from_ordered_sequence(seq)
        return bst
672535
@Private static int binarySearch(IntList ascendingInts, int value) {
    for (int begin = 0, to = ascendingInts.size();;) {
      if (begin == to) return begin;
      int i = (begin + to) / 2;
      int x = ascendingInts.get(i);
      if (x == value) return i;
      else if (x > value) to = i;
      else begin = i + 1;
    }
  }
603006
def _balanced_strand_gen(base_aligns, limit):
    ''''''
    predicate=lambda align: align.is_reverse
    gen1, gen2 = itertools.tee((predicate(align), align) for align in base_aligns)
    for_strand_gen = (align for pred, align in gen1 if not pred)
    rev_strand_gen = (align for pred, align in gen2 if pred)
    combined_gen = iter_zip(for_strand_gen, rev_strand_gen)
    interleaved_gen = (align for for_rev_aligns in combined_gen for align in for_rev_aligns)
    return itertools.islice(interleaved_gen, limit)
701940
def get_tree(self):
        """"""
        self.ignore.append(inspect.currentframe())
        return self._get_tree(self.root, self.maxdepth)
1056542
def get_tree(cls, parent=None):
        
        if parent:
            depth = parent.get_depth() + 1
            results = [parent]
        else:
            depth = 1
            results = []
        cls._get_tree_recursively(results, parent, depth)
        return results
1059290
def roots(self):
    
    import numpy as np
    return np.roots(list(self.values())[::-1]).tolist()
57767
def _normalize_roots(file_roots):
    '''
    
    '''
    for saltenv, dirs in six.iteritems(file_roots):
        normalized_saltenv = six.text_type(saltenv)
        if normalized_saltenv != saltenv:
            file_roots[normalized_saltenv] = file_roots.pop(saltenv)
        if not isinstance(dirs, (list, tuple)):
            file_roots[normalized_saltenv] = []
        file_roots[normalized_saltenv] = \
                _expand_glob_path(file_roots[normalized_saltenv])
    return file_roots
1306572
def get_all_handleable_roots(self):
        
        nodes = self.get_device_tree()
        return [node.device
                for node in sorted(nodes.values(), key=DevNode._sort_key)
                if not node.ignored and node.device
                and (node.root == '/' or nodes[node.root].ignored)]
1077233
function getTree(root, deps) {
  var tree;

  tree = {};

  populateItem(tree, root, deps);

  return tree;
}
354547
def qbe_tree(graph, nodes, root=None):
    
    if root:
        start = root
    else:
        index = random.randint(0, len(nodes) - 1)
        start = nodes[index]
    # A queue to BFS instead DFS
    to_visit = deque()
    cnodes = copy(nodes)
    visited = set()
    # Format is (parent, parent_edge, neighbor, neighbor_field)
    to_visit.append((None, None, start, None))
    tree = {}
    while len(to_visit) != 0 and nodes:
        parent, parent_edge, v, v_edge = to_visit.pop()
        # Prune
        if v in nodes:
            nodes.remove(v)
        node = graph[v]
        if v not in visited and len(node) > 1:
            visited.add(v)
            # Preorder process
            if all((parent, parent_edge, v, v_edge)):
                if parent not in tree:
                    tree[parent] = []
                if (parent_edge, v, v_edge) not in tree[parent]:
                    tree[parent].append((parent_edge, v, v_edge))
                if v not in tree:
                    tree[v] = []
                if (v_edge, parent, parent_edge) not in tree[v]:
                    tree[v].append((v_edge, parent, parent_edge))
            # Iteration
            for node_edge, neighbor, neighbor_edge in node:
                value = (v, node_edge, neighbor, neighbor_edge)
                to_visit.append(value)
    remove_leafs(tree, cnodes)
    return tree, (len(nodes) == 0)
1212531
public static <N extends AbstractDTNode<?, ?, ?, N>> Iterator<N> innerNodeIterator(N root) {
        return Iterators.filter(nodeIterator(root), n -> !n.isLeaf());
    }
90828
def flatten_tree(test, enumerator, exp):
  
  return sum((flatten_tree(test, enumerator, subx) for subx in enumerator(exp)), []) if test(exp) else [exp]
49980
private static BinRelation extractPolar(DTree tree) {
        // TODO: HERE.
        DNode rootVerb = tree.getRoots().get(0);
//        rootVerb.getChildren().
        BinRelation binRelation = new BinRelation();
        return binRelation;
    }
710891
function get(tree, i) {
	if (i < 0 || i >= tree.size) {
		return undefined;
	}
	var offset = (0, _util.tailOffset)(tree);
	if (i >= offset) {
		return tree.tail[i - offset];
	}
	return (0, _util.getRoot)(i, tree.root);
}
532161
def maxTreeDepthDivide(rootValue, currentDepth=0, parallelLevel=2):
    """"""
    thisRoot = shared.getConst('myTree').search(rootValue)
    if currentDepth >= parallelLevel:
        return thisRoot.maxDepth(currentDepth)
    else:
        # Base case
        if not any([thisRoot.left, thisRoot.right]):
            return currentDepth
        if not all([thisRoot.left, thisRoot.right]):
            return thisRoot.maxDepth(currentDepth)

        # Parallel recursion
        return max(
            futures.map(
                maxTreeDepthDivide,
                [
                    thisRoot.left.payload,
                    thisRoot.right.payload,
                ],
                cycle([currentDepth + 1]),
                cycle([parallelLevel]),
            )
        )
214070
def get_roots(self):
        
        return [node for node, in_degree in dict(self.in_degree()).items() if in_degree == 0]
104295
private IQTree liftTree(IQTree queryTree, VariableGenerator variableGenerator) {
        if (queryTree instanceof UnaryIQTree)
            return liftUnary((UnaryIQTree) queryTree, variableGenerator);
        else if (queryTree instanceof NaryIQTree)
            return liftNary((NaryIQTree) queryTree, variableGenerator);
        else if (queryTree instanceof BinaryNonCommutativeIQTree)
            return liftBinaryNonCommutative((BinaryNonCommutativeIQTree) queryTree, variableGenerator);
        // Leaf node
        else
            return queryTree;
    }