fix TreeItem::accumulate and add const version

Authored by alcinos on Jun 22 2018, 6:33 PM.