Iterating through types of a Union in a type-stable manner

Take a look at this thread and other threads that are referenced in it: Macro to write function with many conditionals

There is no simple answer, although there are many possibilities.