improvements to tree reducer macro