Tree random element

The idea is good if we don’t want to cover the whole tree (just the k first), however to cover the whole tree, wouldn’t we have to execute rand:random() in each iteration (rand operations are quite expensive)?