docs: function _doc_to_tree_node(doc, parent_id){
  
      var retnode = {};
  
      // ID.
      var raw_id = doc['id'];
      var safe_id = raw_id; // need to process?
      retnode['attr'] = { "id" : safe_id }; 
  
      // Label (with fallback).
      var label = doc['label'];
      if( ! label || label == '' ){
  	label = raw_id;
      }else{
  	label = label + ' (' + raw_id + ')';
      }
  
      // Set anchor title and href.
      var detlink = linker.url(raw_id, 'term');
      retnode['data'] = {"title" : label,
  		       "attr": {"href": detlink}};
  
      // Turn to graph, get kids.
      var graph = new bbop.model.graph();
      graph.load_json(jQuery.parseJSON(doc['topology_graph']));
      var kids = graph.get_child_nodes(doc['id']);
  
      // Add state and kid_query.
      if( ! kids || kids.length == 0 ){
  	// No kids...
      }else{
  	// No kids, make sure the node is closed.
      	retnode['state'] = 'closed';
  
  	// Collect kid info for the query to get them later.
  	var qbuff = [];
  	bbop.core.each(kids,
  		       function(kid){
  			   qbuff.push('id:"' + kid.id() + '"');
  		       });
  	retnode['attr']['kid_query'] = qbuff.join(' OR ');
      }
  
      // If the parent_id is defined, use that to pull the relationship
      // out of the graph and get a more appropriate icon.
      if( parent_id ){
  
  	// Try and dig out the rel to display.
  	var edges = graph.get_edges(raw_id, parent_id);
  	if( edges && edges.length ){
  	    var weight = {
  		'is_a': 3,
  		'part_of': 2
  	    };
  	    var unknown_rel_weight = 1;
  	    edges.sort(
  		function(a, b){
  		    var aw = weight[a.predicate_id()];
  		    if( ! aw ){ aw = unknown_rel_weight; }
  		    var bw = weight[b.predicate_id()];
  		    if( ! bw ){ bw = unknown_rel_weight; }
  		    return bw - aw;
  		});
  
  	    // Add it in a brittle way.
  	    var prime_rel = edges[0].predicate_id();
  	    retnode['data']['icon'] = 
  	    	server_meta.image_base() + '/' + prime_rel + '.gif';
  	}
      }
  
      return retnode;
  }