'How can I safely traverse a template linked list in which every node is also a template?

I'm trying to make a very basic hash table for an assignment--at this point, it's more of a linked list. I'm having a lot of trouble safely traversing this linked list (checking for null values, etc.) without encountering errors due to the fact that both the hash table class, MyHashTable, and the hash entry struct, MyHashEntry, are templates. At this point, every conditional is throwing an error. I've posted a snippet of my code below. If anyone can point me in the right direction, it would be much appreciated!

template<class K, class V>
bool MyHashTable<K, V>::insert(K key, V value)
{
    MyHashEntry<K, V>* temp;
    // table is a private member of class MyHashTable. Its type is MyHashEntry<K, V>**
    // I believe it acts as a pointer to the pointer of the first entry.
    if (table == NULL)
    {
        table = new MyHashEntry<K, V>*;
        *table = new MyHashEntry<K, V>;
    }
        
    temp = *table;
    // Every struct consists of just K key, V value, and MyHashEntry<K, V>* next
    while (temp->key != NULL && temp->next != NULL)
    {
        temp = temp->next;
    }
    if (temp->key == NULL)
    {
        temp->key = key;
        temp->value = value;
    }
    else
    {
        temp->next = new MyHashEntry<K, V>;
        temp = temp->next;
        temp->key = key;
        temp->value = value;
    }
    //count and numOfBuckets are also private member variables of MyHashTable
    count++;
    if (count > numOfBuckets)
    {
        numOfBuckets = count;
    }
}
c++


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source