Get simple tree as list.
7333
public function getSimpleTree($fields=array(),$transfields=array(),$lang='',$wh=array()){
		$lang=$this->detectLanguage($lang);
		//
		$cachekey=$this->tableName.':simpletree:'.$lang;
		if(!empty($wh)){
			$cachekey.=':wh('.implode(';',$wh).')';
		}
		//Try to get simple tree from internal cache...
		static $cache_simpletree=array();
		if(isset($cache_simpletree[$cachekey])){
			return $cache_simpletree[$cachekey];
			}
		//
		$bcache=\Brilliant\BFactory::getCache();
		if($bcache){
			$res=$bcache->get($cachekey);
			if(($res!==false)&&($res!==NULL)){
				$this->cache_simpletree[$lang]=$res;
				return $res;
				}
			}
		//Load simle cities names.
		if(!$db=\Brilliant\BFactory::getDBO()){return NULL;}
		$qr='SELECT `'.$this->primaryKeyName.'`';
		foreach($fields as $fld){
			$qr.=', `'.$fld.'`';
			}
		foreach($transfields as $fld){
			$qr.=', `'.$fld.'_'.$lang.'` as `'.$fld.'`';
			}
		$qr.=' FROM `'.$this->tableName.'`';
		if(!empty($wh)){
			$qr.=' WHERE ('.implode(' AND ',$wh).')';
			}
		$qr.=' ORDER BY `'.$this->leftKeyName.'`;';
		$q=$db->Query($qr);
		if(empty($q)){
			return $res;
			}
		//
		$res=array();
		while($l=$db->fetch($q)){
			$id=(int)$l[$this->primaryKeyName];
			$val=array();
			$val[$this->primaryKeyName]=$id;
			foreach($fields as $fld){
				$val[$fld]=$l[$fld];
				}
			foreach($transfields as $fld){
				$val[$fld]=$l[$fld];
				}
			$xval=(object)$val;
			$this->getSimpleTreeFilterItem($xval);
			$res[$id]=$xval;
			}
		$this->cache_simpletree[$cachekey]=$res;
		if($bcache){
			$bcache->set($cachekey,$res,3600);//1 hour
			}
		return $res;
		}
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
65097
def get_list(key, *default, **kwargs):
    """"""
    separator = kwargs.get('separator', ' ')
    return get_env(key, *default, coerce=lambda x: x.split(separator))
474769
def get_children(self):
        """"""
        if self.is_leaf():
            return get_result_class(self.__class__).objects.none()
        return get_result_class(self.__class__).objects.filter(
            depth=self.depth + 1,
            path__range=self._get_children_path_interval(self.path)
        ).order_by(
            'path'
        )
723966
private function getList(Tree $tree, SearchService $search_service): array
    {
        $places = $search_service->searchPlaces($tree, '')
            ->sort(static function (Place $x, Place $y): int {
                return $x->gedcomName() <=> $y->gedcomName();
            })
            ->all();

        $numfound = count($places);

        if ($numfound === 0) {
            $columns = [];
        } else {
            $divisor = $numfound > 20 ? 3 : 2;
            $columns = array_chunk($places, (int) ceil($numfound / $divisor));
        }

        return [
            'columns' => $columns,
        ];
    }
275910
function tree(list) {
  const mapped = {}; // { id: name } 形式方便取值

  list.forEach((it) => {
    mapped[it.id] = it;
  });

  const result = [];

  list.forEach((it) => {
    if (it.pid === '') {
      result.push(it);
    } else {
      const parent = mapped[it.pid];
      if (parent) {
        if (!parent.children) {
          parent.children = [];
        }
        parent.children.push(it);
      }
    }
  });

  return result;
}
1309540
static  function toTree($list,$parent_field = 'parent_id',$id_field='id',$children_field='children') {
        $map = self::groupBy($list);
        $data=[];
        foreach ($list as $item) {
            $item->text=$item->name;
            if(is_object($item)){
                if(!$item->$parent_field){
                    $item->$children_field=$map[$item->$id_field];
                    $data[]=$item;
                }
            }
        }
        return $data;
    }
692954
def tree():
    
    root = ('', logging.root, [])
    nodes = {}
    items = list(logging.root.manager.loggerDict.items())  # for Python 2 and 3
    items.sort()
    for name, logger in items:
        nodes[name] = node = (name, logger, [])
        i = name.rfind('.', 0, len(name) - 1)  # same formula used in `logging`
        if i == -1:
            parent = root
        else:
            parent = nodes[name[:i]]
        parent[2].append(node)
    return root
781938
def get_tree(self, process_name):
        
        for tree_name, tree in self.trees.items():
            if process_name in tree:
                return tree
869714
def pretty_tree(x, kids, show):
    
    (MID, END, CONT, LAST, ROOT) = (u'|-- ', u'`-- ', u'|   ', u'    ', u'')

    def rec(x, indent, sym):
        line = indent + sym + show(x)
        xs = kids(x)
        if len(xs) == 0:
            return line
        else:
            if sym == MID:
                next_indent = indent + CONT
            elif sym == ROOT:
                next_indent = indent + ROOT
            else:
                next_indent = indent + LAST
            syms = [MID] * (len(xs) - 1) + [END]
            lines = [rec(x, next_indent, sym) for x, sym in zip(xs, syms)]
            return u'\n'.join([line] + lines)

    return rec(x, u'', ROOT)
331067
def ls(self):
        
        tree = self.ls_tree()
        return [t.get('file') for t in tree if t.get('file')]
848832
def get_children_treepos(self, treepos):
        """"""
        children_treepos = []
        for i, child in enumerate(self.dgtree[treepos]):
            if isinstance(child, nltk.Tree):
                children_treepos.append(child.treeposition())
            elif is_leaf(child):
                # we can't call .treeposition() on a leaf node
                treepos_list = list(treepos)
                treepos_list.append(i)
                leaf_treepos = tuple(treepos_list)
                children_treepos.append(leaf_treepos)
        return children_treepos
1077140
def object_to_items(data_structure):
    """"""
    items = []
    # Get all items from dict
    try:
        items = list(data_structure.__dict__.items())
    except:
        pass
    # Get all slots
    hierarchy = [data_structure]
    try:
        hierarchy += inspect.getmro(data_structure)
    except:
        pass
    slots = []
    try:
        for b in hierarchy:
            try:
                slots += b.__slots__
            except:  # pragma: no cover
                pass
    except:  # pragma: no cover
        pass
    # Get attrs from slots
    for x in slots:
        items.append((x, getattr(data_structure, x)))
    return items
227887
def get_subtree(self, tree, xpath_str):
        """"""
        return tree.xpath(xpath_str, namespaces=self.namespaces)
418428
def get_raw(tree):
    
    if isinstance(tree, Tree):
        words = []
        for child in tree:
            words.append(get_raw(child))
        return ' '.join(words)
    else:
        return tree
822642
def simplify_list(maybe_list):
    """"""
    if isinstance(maybe_list, MutableSequence):
        is_list = aslist(maybe_list)
        if len(is_list) == 1:
            return is_list[0]
    return maybe_list
404506
def to_tree(self):
        
        tree = TreeLibTree()
        for node in self:
            tree.create_node(node, node.node_id, parent=node.parent)
        return tree