Searching the list of node_ids is O(N) in the # of ids. Instead, just look for the id in the hash table, which is much faster.
Also consider eliminating the node_ids array entirely and have get_nodes return node_map.keys(), which will be in the insertion order