original_string: protected function buildTree(array $simpleTree, $tree = [])
      {
          foreach ($simpleTree as $item) {
              if (!isset($this->collection[$item['id']])) {
                  continue;
              }
  
              $content = $this->collection[$item['id']];
  
              unset($this->collection[$item['id']]); // TODO Fix multi-usage of single item
  
              if (isset($item['__children']) && count($item['__children'])) {
                  $content['__children'] = $this->buildTree($item['__children']);
              } else {
                  $content['__children'] = [];
              }
  
              $tree[] = $content;
          }
  
          return $tree;
      }
code: protected function buildTree(array $simpleTree, $tree = [])
      {
          foreach ($simpleTree as $item) {
              if (!isset($this->collection[$item['id']])) {
                  continue;
              }
  
              $content = $this->collection[$item['id']];
  
              unset($this->collection[$item['id']]); // TODO Fix multi-usage of single item
  
              if (isset($item['__children']) && count($item['__children'])) {
                  $content['__children'] = $this->buildTree($item['__children']);
              } else {
                  $content['__children'] = [];
              }
  
              $tree[] = $content;
          }
  
          return $tree;
      }
code_tokens: protected function buildTree ( array $ simpleTree , $ tree = [ ] ) { foreach ( $ simpleTree as $ item ) { if ( ! isset ( $ this -> collection [ $ item [ 'id' ] ] ) ) { continue ; } $ content = $ this -> collection [ $ item [ 'id' ] ] ; unset ( $ this -> collection [ $ item [ 'id' ] ] ) ; // TODO Fix multi-usage of single item if ( isset ( $ item [ '__children' ] ) && count ( $ item [ '__children' ] ) ) { $ content [ '__children' ] = $ this -> buildTree ( $ item [ '__children' ] ) ; } else { $ content [ '__children' ] = [ ] ; } $ tree [ ] = $ content ; } return $ tree ; }
docstring: Build the tree from the simpletree and the collection
  
  @param array $simpleTree
  @param array $tree
  @return array
docstring_tokens: Build the tree from the simpletree and the collection