Added option to reduce the tree before looping over all the entries