In the book's algorithm 18 it says Best ← Pi for this line, which is inside of a for loop for each individual Pi ∈ P do. Here, you simply grab the first element of childArr each while loop pass-through instead of doing a for loop inside the while loop.