Altered function logic

Altered funciton logic to be like tree method ```accumulate_to_ancestor```. Runs significantly faster in tests and returns correct results on the case that @wasade identified as problematic.
Resolves @josenavas's comment
Resolved @wasades' comment on 2508