My gut instinct is that the knownKeywords variable is available only in the jAlbum Explore view. During album generation, I'd guess that it isn't, and that you just have to traverse the object tree and build an array.
It does seem to be tied to the explore view, but I thought it would be available in init.bsh as you can usually access those things in an external tool. It might need accessibility setting though.
If it can be accessed, assuming it is the right parameter, it would make it much easier than doing it yourself.