Fixed code to handle some cases that would break the trie

The following two examples that will not yield correct results prior to my modifications:

------------------------------
Example 1:
trie.insert("abc#");
trie.insert("ab#");
trie.insert("abb#");

------------------------------
Example 2:
trie.insert("test#");
trie.insert("tests#");
trie.insert("testss#");
trie.insert("tear#");