Trie implementation for PHP