You could build a microflow with standard actions, which will be huge
Or you could divert to a Microflow Java Action, or a Nanoflow JavaScript Action if you like
Cool challenge, it could have been “maker of the month challenge”.
It does not have to be huge:
I didnt test it, but it should work something like this.