Instead of recursively calling SerializeMany and peeling off one
argument at a time, use a fold expression. This simplifies the code,
makes it most likely faster because it reduces the number of function
calls, and compiles faster because there are fewer template
instantiations.
This is a partial backport of core#28203
https://github.com/bitcoin/bitcoin/pull/28203/commits/bd08a008b42dac921bd9c031637e378899c1cd1d
https://github.com/bitcoin/bitcoin/pull/28203/commits/1403d181c106bc271ad2522adebde07c7850069b