Go and get the initial results for building our tree.
168738
function DDInit(){

    ll('');
    ll('DrillExp.js');
    ll('DDInit start...');

    var gconf = new bbop.golr.conf(amigo.data.golr);
    var gm = new bbop.golr.manager.jquery(server_meta.golr_base(), gconf);
    //gm.set_personality('bbop_ont'); // profile in gconf
    gm.add_query_filter('document_category', 'ontology_class', ['*']);
    
    // Let's limit ourselves to 100 rows returned so we don't overload
    // while (dumb) browsing.
    gm.set('rows', 100);

    // Let's capture an initial url (one that gets the roots), then
    // reset.
    gm.set_query('id:"GO:0008150" or id:"GO:0005575" or id:"GO:0003674"');
    var reset_url = gm.get_query_url();
    gm.reset_query();

    // Ready tree with response.
    var did = '#drilldown';
    jQuery(did).jstree(
	{
	    "json_data" : {
	        "ajax" : {
		    "type": 'GET',
		    "dataType": 'jsonp',
		    "jsonp": 'json.wrf',
	            "url" : function (n) {
			var retval = reset_url;
			if( !n || ! n.attr || ! n.attr("id") ){
			    ll('url: initial');
			}else{
			    ll('url: open');

			    // Get id.
			    var attr_id = n.attr("id");

			    if( n.attr('kid_query') ){
				gm.set('parent', n.attr('id'));
				gm.set('q', n.attr('kid_query'));
				retval = gm.get_query_url();
			    }else{
				retval = null;
			    }
			}
			ll('try url: ' + retval);
	                return retval;
	            },
	            "error" : function(e) {
			ll('ERROR: ' + e);
			//throw new Error('...');
		    },
	            "success" : function(json_data) {

			//ll('SUCCESS on data');

			// Figure out if there was a parent and
			// capture the id if there was.
			var parent_id = null;
			if( json_data &&
			    json_data.responseHeader &&
			    json_data.responseHeader.params &&
			    json_data.responseHeader.params.parent ){
				parent_id = json_data.responseHeader.params.parent;
			}

			// Gather the documents found.
			var resp = new bbop.golr.response(json_data);
			var docs = resp.documents();
			var json_nodes = [];
			var each = bbop.core.each;
			each(docs,
			     function(doc){
				 json_nodes.push(_doc_to_tree_node(doc,
								   parent_id));
			     });
			
			// Alpha sort, but get GO stuff first.
			json_nodes.sort(
			    function(a, b){

				// First id suffix-ish compare (dirty)
				// for GO.
				var foo = 0;
				var a_id = a['attr']["id"].substr(0, 2);
				var b_id = b['attr']["id"].substr(0, 2);
				if (a_id == 'GO' && b_id != 'GO' ){
				    foo = -1;
				}else if (a_id != 'GO' && b_id == 'GO' ){
				    foo = 1;
				}else{
				    // Then a general suffix compare.
				    foo = a_id.localeCompare(b_id);

				    if( foo == 0 ){
					// And finally an alpha label
					// comparison.
					var a_t = a['data']['title'];
					var b_t = b['data']['title'];
					foo = a_t.localeCompare(b_t);
				    }
				}
				return foo;
			    });
			
	                return json_nodes;
	            }
	        }
	    },
	    "plugins" : ["json_data", "themeroller"]});
    // Revoved the bits that override the normal HTML click
    // functionality. Nice to know it's there though.
    //     "plugins" : ["json_data", "themeroller", "ui"]
    // }).bind("select_node.jstree",
    // 	// TODO: Probably want a callback to the server here
    // 	// to get more detailed information; just a
    // 	// placeholder linker for now.
    // 	function(e, data){
    // 	    var attr_id = data.rslt.obj[0].id;
    // 	    var linky = api.link.term({acc: attr_id});
    // 	    window.location.href = linky;
    // 	    // Or perhaps a pop-up info window?
    // 	    // var dia = '<div>' +
    // 	    // 	api.html.term_link(attr_id,
    // 	    // 			     'Link to ' + attr_id + '.') +
    // 	    // 	'</div>';
    // 	    // jQuery(dia).dialog({closeOnEscape: true,
    // 	    // 			modal: true,
    // 	    // 			title: 'Quick info about: ' + attr_id});
    // 	});

    ll('DDInit done.');
}
1179752
def _build_tree(self, position, momentum, slice_var, direction, depth, stepsize, position0, momentum0):
        
        if depth == 0:

            position_bar, momentum_bar, candidate_set_size, accept_set_bool =\
                self._initalize_tree(position, momentum, slice_var, direction * stepsize)

            alpha = min(1, self._acceptance_prob(position, position_bar, momentum, momentum_bar))

            return (position_bar, momentum_bar, position_bar, momentum_bar, position_bar,
                    candidate_set_size, accept_set_bool, alpha, 1)

        else:
            (position_backward, momentum_backward, position_forward, momentum_forward, position_bar,
             candidate_set_size, accept_set_bool, alpha, n_alpha) =\
                self._build_tree(position, momentum, slice_var,
                                 direction, depth - 1, stepsize, position0, momentum0)

            if accept_set_bool == 1:
                if direction == -1:
                    # Build tree in backward direction
                    (position_backward, momentum_backward, _, _, position_bar2, candidate_set_size2, accept_set_bool2,
                     alpha2, n_alpha2) = self._build_tree(position_backward, momentum_backward, slice_var, direction,
                                                          depth - 1, stepsize, position0, momentum0)
                else:
                    # Build tree in forward direction
                    (_, _, position_forward, momentum_forward, position_bar2, candidate_set_size2, accept_set_bool2,
                     alpha2, n_alpha2) = self._build_tree(position_forward, momentum_forward, slice_var, direction,
                                                          depth - 1, stepsize, position0, momentum0)

                if np.random.rand() < candidate_set_size2 / (candidate_set_size2 + candidate_set_size):
                    position_bar = position_bar2

                alpha += alpha2
                n_alpha += n_alpha2
                accept_set_bool, candidate_set_size =\
                    self._update_acceptance_criteria(position_forward, position_backward, momentum_forward,
                                                     momentum_backward, accept_set_bool2, candidate_set_size,
                                                     candidate_set_size2)

            return (position_backward, momentum_backward, position_forward, momentum_forward, position_bar,
                    candidate_set_size, accept_set_bool, alpha, n_alpha)
321010
def get_root(self):
        """"""
        if self.lft == 1:
            return self
        return get_result_class(self.__class__).objects.get(
            tree_id=self.tree_id, lft=1)
289810
def _build_tree(self):
        

        groups = self._groups or self.get_children_paths(self.root_path)
        for group in groups:
            node = Node(name=group, parent=self.root)
            self.root.children.append(node)
            self._init_sub_groups(node)
1118184
def build_fptree(self, transactions, root_value,
                     root_count, frequent, headers):
        
        root = FPNode(root_value, root_count, None)

        for transaction in transactions:
            sorted_items = [x for x in transaction if x in frequent]
            sorted_items.sort(key=lambda x: frequent[x], reverse=True)
            if len(sorted_items) > 0:
                self.insert_tree(sorted_items, root, headers)

        return root
856909
function buildTree(tokens) {
  var items = _.map(tokens, function(token) {
    return tartan.utils.node.newStripe(token);
  });
  var isReflected = (tokens.length >= 2) && (tokens[0].isPivot);
  return tartan.utils.node.newRootBlock(items, isReflected);
}
781650
private void buildCoverTree() {
        ArrayList<DistanceSet> pointSet = new ArrayList<>();
        ArrayList<DistanceSet> consumedSet = new ArrayList<>();

        E point = data[0];
        int idx = 0;
        double maxDist = -1;

        for (int i = 1; i < data.length; i++) {
            DistanceSet set = new DistanceSet(i);
            double dist = distance.d(point, data[i]);
            set.dist.add(dist);
            pointSet.add(set);
            if (dist > maxDist) {
                maxDist = dist;
            }
        }

        root = batchInsert(idx, getScale(maxDist), getScale(maxDist), pointSet, consumedSet);
    }
173263
def as_tree(context):
    """"""

    tree = _build_tree(context, 2, 1)
    if type(tree) == dict:
        tree = [tree] 
    
    return Response(content_type='application/json', body=json.dumps(tree))
724280
public static void build(
            final Key jobKey,
            final Key modelKey,
            final DRFParams drfParams,
            final Data localData,
            int ntrees,
            int numSplitFeatures,
            int[] rowsPerChunks) {
      Timer  t_alltrees = new Timer();
      Tree[] trees      = new Tree[ntrees];
      Log.info(Log.Tag.Sys.RANDF,"Building "+ntrees+" trees");
      Log.info(Log.Tag.Sys.RANDF,"Number of split features: "+ numSplitFeatures);
      Log.info(Log.Tag.Sys.RANDF,"Starting RF computation with "+ localData.rows()+" rows ");

      Random rnd = Utils.getRNG(localData.seed() + ROOT_SEED_ADD);
      Sampling sampler = createSampler(drfParams, rowsPerChunks);
      byte producerId = (byte) H2O.SELF.index();
      for (int i = 0; i < ntrees; ++i) {
        long treeSeed = rnd.nextLong() + TREE_SEED_INIT; // make sure that enough bits is initialized
        trees[i] = new Tree(jobKey, modelKey, localData, producerId, drfParams.max_depth, drfParams.stat_type, numSplitFeatures, treeSeed,
                i, drfParams._exclusiveSplitLimit, sampler, drfParams._verbose, drfParams.regression, !drfParams._useNonLocalData, ((SpeeDRFModel)UKV.get(modelKey)).score_pojo);
      }

      Log.info("Invoking the tree build tasks on all nodes.");
      DRemoteTask.invokeAll(trees);
      Log.info(Log.Tag.Sys.RANDF,"All trees ("+ntrees+") done in "+ t_alltrees);
    }
1047885
def build_tree(self):
        
        self._tree_store = []
        self.node(np.arange(0, self.data_size, dtype=np.int), self.vectorised_array, self.observed)
225259
def start_tree(self, tree, filename):
        
        self.used_names = tree.used_names
        self.set_filename(filename)
        self.numbers = itertools.count(1)
        self.first_log = True
1083025
def setup_tree(self):
        """"""
        self.tree.insert("", tk.END, text="Example 1", iid="1")
        self.tree.insert("", tk.END, text="Example 2", iid="2")
        self.tree.insert("2", tk.END, text="Example Child")
        self.tree.heading("#0", text="Example heading")
799597
private void initTopicTree() {
        try {
            Object data = view.getViewData();
            
            if (!(data instanceof TopicTree)) {
                return;
            }
            
            TopicTree topicTree = (TopicTree) data;
            HelpTopicNode baseNode;
            
            if (helpViewType == HelpViewType.TOC) {
                HelpTopic topic = new HelpTopic(null, hs.getName(), hs.getName());
                baseNode = new HelpTopicNode(topic);
                rootNode.addChild(baseNode);
            } else {
                baseNode = rootNode;
            }
            
            initTopicTree(baseNode, topicTree.getRoot());
            
        } catch (IOException e) {
            return;
        }
        
    }
945214
public void startOnInit(Result<I> result)
  {
    
    DeployFactory2<I> builder = builder();
    
    if (builder == null) {
      result.ok(null);
      return;
    }
    
    if (! _lifecycle.toInit()) {
      result.ok(get());
      return;
    }
    
    _strategy.startOnInit(this, result);
  }
145290
def do_tree(self, line):
        """"""
        opts = self.TREE_OPTS
        line = line.split()
        _pattern = ""

        if not self.current:
            self._help_noontology()
            return

        if len(line) == 0:
            # default contextual behaviour [2016-03-01]
            line = ["classes"]

        if line[0] not in opts:
            self.help_tree()
            return

        elif line[0] == "classes":
            g = self.current['graph']
            if g.all_classes:
                g.printClassTree(showids=False, labels=False, showtype=True)
                self._print("----------------", "TIP")
            else:
                self._print("No classes available.")

        elif line[0] == "properties":
            g = self.current['graph']
            if g.all_properties:
                g.printPropertyTree(showids=False, labels=False, showtype=True)
            else:
                self._print("No properties available.")

        elif line[0] == "concepts":
            g = self.current['graph']
            if g.all_skos_concepts:
                g.printSkosTree(showids=False, labels=False, showtype=True)
            else:
                self._print("No concepts available.")

        else:  # should never arrive here
            pass
65487
def _from_tree_results(self, tree):
        
        self._from_tree_type_changes(tree)
        self._from_tree_default(tree, 'dictionary_item_added')
        self._from_tree_default(tree, 'dictionary_item_removed')
        self._from_tree_value_changed(tree)
        self._from_tree_unprocessed(tree)
        self._from_tree_default(tree, 'iterable_item_added')
        self._from_tree_default(tree, 'iterable_item_removed')
        self._from_tree_default(tree, 'attribute_added')
        self._from_tree_default(tree, 'attribute_removed')
        self._from_tree_set_item_removed(tree)
        self._from_tree_set_item_added(tree)
        self._from_tree_repetition_change(tree)
1086340
def build(self, tool):
        """"""

        tools = self._validate_tools(tool)
        if tools == -1:
            return -1

        result = 0

        for build_tool in tools:
            builder = ToolsSupported().get_tool(build_tool)
            # None is an error
            if builder is None:
                logger.debug("Tool: %s was not found" % builder)
                result = -1
                continue

            logger.debug("Building for tool: %s", build_tool)
            logger.debug(self.generated_files)
            if builder(self.generated_files[build_tool], self.settings).build_project() == -1:
                # if one fails, set to -1 to report
                result = -1
        return result