Where’s the detour? Doing this with nodesBetween seems like it’ll be both more code and more error-prone, since that’ll call your callback for all nodes in a range, not just the node you’re interested in.
Ah, you mean the caller would have those values already. I think that’s because passing the index to the callback wasn’t something nodesBetween did, initially, and this code was written against the old interface. Feel free to open a pull request to optimize that.
I was wrong, I understand now why the detour is needed. The parent from nodesBetween is from the original state and the lookup is needed to get the parent from the current state if previous steps changed the content of the parent.