Ternary Search Tree in Python