public function hasLoop(): bool {
        $tortoise = $this->getHead();
        $hare = $this->getHead();

        while ($tortoise !== null && $hare->getNext() !== null) {
            $hare = $hare->getNext()->getNext();

            if (Comparator::equals($tortoise->getValue(), $hare->getValue())) {
                return true;
            }

            $tortoise = $tortoise->getNext();
        }
        return false;
    }