public function delete($key): bool {
        $node = $this->getNodeFromHead($key);
        if (null === $node) {
            return false;
        }
        /** @var Node $head */
        $head = $this->head;
        while (null !== $head) {
            if (Comparator::equals($head->getKey(), $node->getKey())) {
                $this->unset($head);
                $this->hashMap->remove($key);
                return true;
            }
            $head = $head->getNext();
        }
        return false;
    }