Very nice snippet, thanks for sharing.
One question, is it possible if we want to make a navigation between all child containers of a parent container?
eg.
|- parent
|-- container1
|--- doc1
|--- doc2
|--- doc3
|--- doc4
|-- container2
|--- doc1
The snippet will show "Next" on doc4, linked to doc1 of container2.
Basically it will ignore the containers under the specified parent.
Let me know if this doesnt make sense.