IDI-104: Refactor the produceTree() functions to simplify; other clean-up.