The issue was in not going deep in enough in children hierarchy to set the "previous" item pointer. It was setting it only to the next level of children:
- first item
- nested item <--- it would always pick this as a previous while processing the `second item` below
- nested nested item
- - nested nested nested item <--- we should go down the tree to the bottom to find the deepest child
- second item
Fixes #200
The issue was in not going deep in enough in children hierarchy to set the "previous" item pointer. It was setting it only to the next level of children: