a python implementation of the tries structure