Code for building entities trie had incorrect use of loop.