half coded TreePartialSum