Firstly, let us consider a simpler problem: Let us have similar queries, yet
without the "time-stamp", and all nodes are either 0 or 1 (and we would like
the sum). Now if this would be path (not a tree), it could be easily solved
with segment tree (fenwick tree or similar) ... well obviously - simply ask for
answer on segment.