private function visitString(TreeNode $node)
 {
     $tokens = array();
     foreach ($node->getChildren() as $child) {
         $value = $child->getValue();
         if ($value === null || !isset($value['value'])) {
             throw new InvalidArgumentException(sprintf('A token node was expected, got "%s".', $child->getId()));
         }
         $tokens[] = $value['value'];
     }
     return implode($tokens);
 }
 private function leftRotateTree(TreeNode &$root)
 {
     // Pivot = Root.Left
     $pivot = $root->getChild(1);
     // Root.Right = Pivot.Left
     $children = $root->getChildren();
     $children[1] = $pivot->getChild(0);
     // Pivot, rotation side
     $root->setChildren($children);
     // Pivot.Left = Root
     $children = $pivot->getChildren();
     $children[0] = $root;
     $pivot->setChildren($children);
     // Root = Pivot
     $root = $pivot;
 }