When changes and reads are both frequent on a deep tree, number the nodes in pre-order
Walking up is O(h) per change, and walking down is O(s) per read. Number the nodes in pre-order, and every subtree is one unbroken range of numbers.
Predict
Number the regions in pre-order from 0. Europe is 0 and Portugal is 1. Which numbers make up Portugal's subtree?
Pre-order numbers, and the range each subtree covers
Europe
0, 0 to 12
Portugal
1, 1 to 7
Lisbon District
2, 2 to 5
Lisbon
3
Sintra
4
Cascais
5
Porto District
6, 6 to 7
Porto
7
Spain
8, 8 to 12
Andalusia
9, 9 to 11
Seville
10
Granada
11
Catalonia
12
Each tag is the region's number, then the numbers its subtree covers.
Each range runs from the node's own number to the last number inside it. Keep each node's own value in a Fenwick tree, also called a binary indexed tree. It's a plain list where each slot holds the sum of a block of positions ending there, and the blocks have power-of-two sizes. Adding at one position updates the O(logn) blocks that cover it. The total from position 0 to i adds up O(logn) blocks, and a range is one such total minus another. You don't need to write one from memory: name it, give both costs, and say a segment tree does the same job.
A change at Sintra adds to position 4. Portugal's total is the range 1 to 7. Both are O(logn), after an O(n) walk to number the nodes.