Fix bug in tree-accumulation algo