Create an array arr where arr[tin[v]] holds node 's value. Run DFS, assign entry times, and place values in the array.
Now you have a flat array. The subtree of corresponds to range [tin[v], tout[v]] in this array. Any range data structure (segment tree, BIT) can now handle subtree queries. This converts tree problems into array problems you already know how to solve. The flattening step is and only needs to be done once.