protected static function build_tree($all, $parentid) {
        $tree = array();
        foreach ($all as $one) {
            if ($one->get('parentid') == $parentid) {
                $node = new stdClass();
                $node->competency = $one;
                $node->children = self::build_tree($all, $one->get('id'));
                $tree[] = $node;
            }
        }
        return $tree;
    }
protected static function build_tree($all, $parentid) {
        $tree = array();
        foreach ($all as $one) {
            if ($one->get('parentid') == $parentid) {
                $node = new stdClass();
                $node->competency = $one;
                $node->children = self::build_tree($all, $one->get('id'));
                $tree[] = $node;
            }
        }
        return $tree;
    }
protected static function build_tree ( $ all , $ parentid ) { $ tree = array ( ) ; foreach ( $ all as $ one ) { if ( $ one -> get ( 'parentid' ) == $ parentid ) { $ node = new stdClass ( ) ; $ node -> competency = $ one ; $ node -> children = self :: build_tree ( $ all , $ one -> get ( 'id' ) ) ; $ tree [ ] = $ node ; } } return $ tree ; }
Recursively build up the tree of nodes.

@param array $all - List of all competency classes.
@param int $parentid - The current parent ID. Pass 0 to build the tree from the top.
@return node[] $tree tree of nodes
Recursively build up the tree of nodes .