Add recursive implementation of `reduce`