This is a common query in segment trees. The order is what matters. You first check your left child. If you found no answer you check the right child. It is easy to see that the first answer you find is the leftmost.

If it is not clear you can check the function qryMax in this code: 39448626

You want to find the leftmost element that is > x in the range [L, R].

So, if a certain node's range lies completely outside [L, R] or if the maximum in that range ≤ x, discard the node.

Otherwise, go to the left subtree. If there's no answer in the left subtree, go to the right subtree.

If you have reached a leaf, then it is the one you want. The leaf is the leftmost such leaf because we have always gone left-first. The leaf is guaranteed to be > x because we have discarded nodes who's maximum was ≤ x