I don't understand the purpose of Trainer looks like a class with the only for populate the tree. Maybe a class Dictionary with this populate method as the constructor and having the wordsMap and childMap that nodes have, would make more sense to me.