trie.py updated to check if nodes already exist