Well, nothing prevents this to be a 3-5 lines of Python with more suitable data structures:
$ pip install dawg
and then import dawg
words = open('/usr/share/dict/words', 'r').read().splitlines()
d = dawg.DAWG(words)
(this example actually works)