/**
  * @param StackLevel $stack
  * @return array
  */
 private function groupOperators(StackLevel $stack)
 {
     $group = array();
     foreach ($stack->get() as $item) {
         if ($item instanceof StackLevel) {
             $group[] = $this->groupOperators($item);
         } elseif ($item instanceof StackExpression) {
             $group[] = $this->arrangeSet($item);
         } else {
             throw new QueryParserException("Unexpected value in item of type: " . gettype($item));
         }
     }
     return [$stack->getOperator()->get() => $group];
 }