original_string: private function parse(\WP_Query $query = null)
      {
          (is_null($query) && isset($GLOBALS['wp_query'])) and $query = $GLOBALS['wp_query'];
  
          $data = (object)['hierarchy' => [], 'templates' => [], 'query' => $query];
  
          $branches = self::$branches;
  
          // make the branches filterable, but assuring each item still implement branch interface
          if ($this->flags & self::FILTERABLE) {
              $branches = array_filter(
                  (array)apply_filters('brain.hierarchy.branches', $branches),
                  function ($branch) {
                      return is_subclass_of($branch, Branch\BranchInterface::class, true);
                  }
              );
          }
  
          // removed indexes, we added them to make filtering easier
          $branches = array_values($branches);
  
          if ($query instanceof \WP_Query) {
              $data = array_reduce($branches, [$this, 'parseBranch'], $data);
          }
  
          $data->hierarchy = $this->addIndexLeaves($data->hierarchy);
          $data->templates[] = 'index';
          $data->templates = array_values(array_unique($data->templates));
  
          return $data;
      }
code: private function parse(\WP_Query $query = null)
      {
          (is_null($query) && isset($GLOBALS['wp_query'])) and $query = $GLOBALS['wp_query'];
  
          $data = (object)['hierarchy' => [], 'templates' => [], 'query' => $query];
  
          $branches = self::$branches;
  
          // make the branches filterable, but assuring each item still implement branch interface
          if ($this->flags & self::FILTERABLE) {
              $branches = array_filter(
                  (array)apply_filters('brain.hierarchy.branches', $branches),
                  function ($branch) {
                      return is_subclass_of($branch, Branch\BranchInterface::class, true);
                  }
              );
          }
  
          // removed indexes, we added them to make filtering easier
          $branches = array_values($branches);
  
          if ($query instanceof \WP_Query) {
              $data = array_reduce($branches, [$this, 'parseBranch'], $data);
          }
  
          $data->hierarchy = $this->addIndexLeaves($data->hierarchy);
          $data->templates[] = 'index';
          $data->templates = array_values(array_unique($data->templates));
  
          return $data;
      }
code_tokens: private function parse ( \ WP_Query $ query = null ) { ( is_null ( $ query ) && isset ( $ GLOBALS [ 'wp_query' ] ) ) and $ query = $ GLOBALS [ 'wp_query' ] ; $ data = ( object ) [ 'hierarchy' => [ ] , 'templates' => [ ] , 'query' => $ query ] ; $ branches = self :: $ branches ; // make the branches filterable, but assuring each item still implement branch interface if ( $ this -> flags & self :: FILTERABLE ) { $ branches = array_filter ( ( array ) apply_filters ( 'brain.hierarchy.branches' , $ branches ) , function ( $ branch ) { return is_subclass_of ( $ branch , Branch \ BranchInterface :: class , true ) ; } ) ; } // removed indexes, we added them to make filtering easier $ branches = array_values ( $ branches ) ; if ( $ query instanceof \ WP_Query ) { $ data = array_reduce ( $ branches , [ $ this , 'parseBranch' ] , $ data ) ; } $ data -> hierarchy = $ this -> addIndexLeaves ( $ data -> hierarchy ) ; $ data -> templates [ ] = 'index' ; $ data -> templates = array_values ( array_unique ( $ data -> templates ) ) ; return $ data ; }
docstring: Parse all branches.
  
  @param \WP_Query $query
  
  @return \stdClass
docstring_tokens: Parse all branches .