Trie traversal to maximise XOR in a tree but with a condition
You can simply use persistent tries.

Let $T[x]$ denote a trie containing all keys in the path from root to $x$, assume $y$ is a child of $x$, $T[y]$ can be constructed in $O(\log U)$ time from $T[x]$, where $U=2^{32}$. This is trivial even if you use normal tries; but the key point is "persistent" data structures enable you to store all $T[\cdot]$ at the same time. As an intuition, notice that when we construct $T[y]$ from $T[x]$, only $O(\log U)$ nodes in $T[x]$ changes.