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
[1] https://en.m.wikipedia.org/wiki/Directed_acyclic_word_graph