Fredkin trie algorithm in Erlang