Add a better function to get connected nodes using a hash table