refactor: use fold expressions instead of recursive calls in (Un)SerializeMany()
Summary:
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
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D19046