Refactor PHP radix trie