public function buildTree(TokenIterator $iterator) {
    $this->skipped = [];
    $this->skipParent = NULL;
    $this->docComment = NULL;
    $this->skippedDocComment = [];
    $this->iterator = $iterator;
    $this->current = $this->iterator->current();
    $this->currentType = $this->current ? $this->current->getType() : NULL;
    $top = new RootNode();
    $this->top = $top;
    if ($this->currentType && $this->currentType !== T_OPEN_TAG) {
      $node = new TemplateNode();
      // Parse any template statements that proceed the opening PHP tag.
      $this->templateStatementList($node);
      $top->addChild($node);
    }
    if ($this->tryMatch(T_OPEN_TAG, $top, NULL, TRUE, TRUE)) {
      $this->topStatementList($top);
    }
    return $top;
  }