/**
  * Fetch the data object that determines the elimination bracket participants and results
  * 
  * @todo implement the $bracket filter
  * 
  * @param int|null $bracket
  * <br /><b>Optional</b><br />
  * Specify a single bracket to return<br />
  * 
  * @return BBBracketsObject|boolean
  * <br />Return values:<br />
  * <ul>
  *  <li>{@link BBBracketsObject} - default return value</li>
  *  <li>{@link BBMatchObject}[][] - if a <var>$bracket</var> integer was provided, only the array of rounds for that bracket is returned</li>
  *  <li><b>False</b> returned if tournament has no brackets / error communicating with the API</li>
  */
 public function &brackets($bracket = null)
 {
     //Already set
     if (!is_null($this->brackets)) {
         return $this->brackets;
     }
     //Failure
     if (!BBHelper::tournament_has_brackets($this)) {
         return $this->bb->ref($this->set_error('This tournament does not have any brackets to load!'));
     }
     //GOGOGO!
     $result = $this->call(self::SERVICE_LOAD_BRACKETS, array('tourney_id' => $this->id), self::CACHE_TTL_DRAW, self::CACHE_OBJECT_TYPE, $this->id);
     //Failure!
     if ($result->result != BinaryBeast::RESULT_SUCCESS) {
         $this->set_error('Error returned from the API when calling the bracket drawing service, please refer to $bb->result_history for details');
         return $this->bb->ref(false);
     }
     /*
      * Success!
      * 
      * Now pass each returned match through process_draw_match,
      * which will attempt to convert the values into Model objects
      */
     $this->brackets = new stdClass();
     foreach ($result->brackets as $bracket => $rounds) {
         //the API's response is keyed by bracket integer, let's translate for convenience of developers
         $bracket = BBHelper::get_bracket_label($bracket, true);
         $this->brackets->{$bracket} = array();
         foreach ($rounds as $round => $matches) {
             $this->brackets->{$bracket}[$round] = array();
             foreach ($matches as $match) {
                 $this->brackets->{$bracket}[$round][] = $this->process_drawn_match($match);
             }
         }
     }
     //Success! now return the result
     return $this->brackets;
 }