"This code makes sure that the command has a key "cursor" with an array that at least has a key "batchSize" with a value."

If the root field doesn't exist, we need to create it. But we can only do that if it's an array. Exactly what the code says.