refactor trie.py a bit more

make intention of code a bit clearer in trie.py

python supports bit arithmetic and I do think it makes the code a bit easier to understand.