[ATR-28845] Protect against trigger navigation graphs with over uint16_t::max nodes
This provides protection for the crash in [ATR-28845] while work on the proper fix, !74315 (merged), continues.
Change tested against the reproducer on [ATR-30141]. This is a very rare occurrence.
Both choices in the mitigation code block were tested.
Also targets 24.0.52-patches