[v1] Better reduce algorithm

Using the @adrienbrault algorithm.

In the branch v2 the algo was already(10 days ago) fixed,  this new one is simpler and cleaner.

I set the function as private...