Fix bug with hanging nodes due to bottom up order in reduce algo