Here [1] is an approach to implement that snippet. I prefer the initial one as it turns out the deduplicated has the same additions and deletions. Also, if both approaches have the same code overhead, the distinct methods feel cleaner to me.

[1] https://github.com/johngian/remo/commit/0fe209078865fb743dfd8a0e42768f740bc72a75