Thank you, Michael. I've just started to think about same solution.
I'd like to suggest following feature to add to AdWords Scripts in future versions, that could be useful.
To be able to get product ids, categories, brands etc. for each ProductGroup object.
This is what I see in AdWords interface. When I try to edit ProductGroup node, I can see list of all possible child nodes.