original_string: protected function buildNestedArray(array $nodes = [], $parentId = 0)
      {
          $branch = [];
  
          if (empty($nodes)) {
              $nodes = $this->allNodes();
          }
  
          foreach ($nodes as $node) {
              if ($node[$this->parentColumn] === $parentId) {
                  $children = $this->buildNestedArray($nodes, $node[$this->getKeyName()]);
  
                  if ($children) {
                      $node['children'] = $children;
                  }
  
                  $branch[] = $node;
              }
          }
  
          return $branch;
      }
code: protected function buildNestedArray(array $nodes = [], $parentId = 0)
      {
          $branch = [];
  
          if (empty($nodes)) {
              $nodes = $this->allNodes();
          }
  
          foreach ($nodes as $node) {
              if ($node[$this->parentColumn] === $parentId) {
                  $children = $this->buildNestedArray($nodes, $node[$this->getKeyName()]);
  
                  if ($children) {
                      $node['children'] = $children;
                  }
  
                  $branch[] = $node;
              }
          }
  
          return $branch;
      }
code_tokens: protected function buildNestedArray ( array $ nodes = [ ] , $ parentId = 0 ) { $ branch = [ ] ; if ( empty ( $ nodes ) ) { $ nodes = $ this -> allNodes ( ) ; } foreach ( $ nodes as $ node ) { if ( $ node [ $ this -> parentColumn ] === $ parentId ) { $ children = $ this -> buildNestedArray ( $ nodes , $ node [ $ this -> getKeyName ( ) ] ) ; if ( $ children ) { $ node [ 'children' ] = $ children ; } $ branch [ ] = $ node ; } } return $ branch ; }
docstring: Build Nested array.
  
  @param array $nodes
  @param int   $parentId
  
  @return array
docstring_tokens: Build Nested array .