Wrap redundant reduce and reduceRight code in helper

The loops could be further abstracted, but I didn't like how it looked after going that far

Fixes #1734 
Can you explain what you mean by that?