fix recursion in mapreduce_pairwise_impl