Java LONG solution, beats 97%, with brief explanation

I know this is a long solution. but beyond my expectation, it beats 97% Java solution.

It's also using trie, but in this question, the tree is built bit by bit, each bit could be 0 or 1, so it could be a binary tree. Left child is 0, right child is 1. From root down to the first node that has both left and right child, then compare the max XOR of the 2 children.

case 1:
left right
/ \ / \
a b c d
should calc on (a, d), then calc on (b, c) , and get the max value.
case 2:
left right
/ \ / \
a b c
calc on (b, c)
case 3:
left right
/ \ \
a b d
calc on (a,d)
case 4.
left right
/ /
a b
then calc on (a, b). Same case for the right child case.