fix for issue #131 : NPE when reaching a terminal node but not at the end of the word