Finite state machines as data structure for representing ordered sets and maps
Also called DAWGs (Directed Acyclic Word Graphs [1]).  John Resig blogged about a similar problem 5 years ago, for which I wrote a JavaScript solution [2].[1] https://en.m.wikipedia.org/wiki/Directed_acyclic_word_graph[2] https://github.com/mckoss/lookups