[BUGFIX beta] Fix substates for nested routes and auto-generated index routes

Including refactoring to avoid duplication which felt responsible for the initial error.
Warn if FEATURES flagging is used in non-canary, debug builds. Fixes #9302
Merge pull request #9309 from jayphelps/warn-features-non-canary

Warn if FEATURES flagging is used in non-canary, debug build. Fixes #9302
Merge pull request #9308 from BookingSync/fix-substates

[BUGFIX beta] Fix substates for nested routes and auto-generated index routes