-
Even when implementing an old and established algorithm, I'm afraid of `while` statements and always feel like putting in a `if (tries > maxTries) { throw new Error('Exceeded maxTries.') }`. But indeed in this case, the while will always resolve as long as the tree is valid.