[Core] Optimize NthOrder promotion checker.

Fixes #821.