"A two-envelopes puzzle"

The manual is right. The coin flips just generate the number $X$. If both envelopes contain numbers smaller than $X$, you have a random choice among the envelopes because you will take the second one. If both envelopes contain numbers greater than $X$, you have a random choice because you will take the first one. If one is greater than $X$ and the other is less, you will certainly pick the correct one, so if there is any probability this situation obtains you have a strictly greater than $\frac 12$ chance of picking the correct envelope. You can generate $X$ any way you want with the same effect as long as it has positive probability to be in each interval $(k,k+1)$. The argument tacitly assumes that it is possible one is below $X$ and one is above $X$. The reason to do the coin flipping is to get a distribution where all naturals plus $\frac 12$ have some chance to be chosen. This guarantees that there is some chance $X$ is between the two numbers.


Actually it seems logical to me.

The chance that you will change is larger for the wrong envelope.


So long as $X$ has a positive probability of being between the values in the two envelopes, it can help improve your decision making, by slightly biasing your decision upwards in the way indicated.

The coin toss version works since it has a positive probability of being in each gap between positive integers, no matter what are the distributions of the amounts in the two envelopes.

Your leaves on the tree idea might or might not help, as it runs the risk of being too high (you can already see there are lots of leaves, perhaps well in excess of the amounts in the envelopes) or of being too small (there is a limit to the the number of leaves), depending on the distributions of the amounts in the envelopes and of leaves on the tree. And you do not know those distributions.