private function moveWithCondition(callable $condition, $direction = self::DIR_FORWARD)
    {
        while ($condition()) {
            $this->move($direction);

            if (!$this->valid()) {
                throw $this->getOutOfBoundsException();
            }
        }

        return $this;
    }