/** * Removes all invalid iterators from the top of the stack. * @return void */ private function discardInvalid() { while ($this->valid() && !$this->stack->last()->valid()) { $this->pop(); } }