/**
  * Removes from the list the last element that was returned by next()
  * @return void
  * @throws IllegalStateException
  */
 public function remove()
 {
     if ($this->canRemove) {
         $this->list->removeAt($this->index);
         $this->canRemove = false;
     } else {
         throw new IllegalStateException("Cannot remove element unless next has been called");
     }
 }
 /**
  * Outputs to stdout a simplistic representation of this node and
  * it's children
  * @param number $level
  */
 public function toString($level = 0)
 {
     $output = "";
     for ($i = 0; $i < $level; $i++) {
         $output .= "\t";
     }
     $output .= print_r($this->value(), true);
     $output .= "\n";
     $iterator = $this->children->iterator();
     while ($iterator->hasNext()) {
         $output .= $iterator->next()->toString($level + 1);
     }
     return $output;
 }