Share code to compute the type of a union.

This does not change the generated code.
Remove the glob import for UnionTypes.
Merge pull request #3443 from Ms2ger/uniontypes

Remove the glob import for UnionTypes; r=jdm