There is no instruction on how to use the indexing, and the example code is a copy/paste from above.
In context, I'm looking for a way to iterate through all layers, not just top-level ones, and I can't pass a layer through a modal call, so I need an index, but I can't find out how to get to and use it.