implementation of tries