ND2: prevent backwards seeking when reading tags

This prevents an infinite loop which results in a StackOverflowError.

Fixes #10485.