0
Simplify deeply nested conditionals without changing behavior
Simplify the deeply nested if/else or switch logic below. Rules:
1. Preserve behavior exactly, including any subtle order-dependent checks (list any you find, so I can confirm you preserved them correctly).
2. Prefer guard clauses / early returns over nested if-else pyramids.
3. Where multiple conditions test the same variable, consider whether a lookup table, strategy map, or polymorphism would be clearer than a long conditional chain, but only propose it if it's genuinely simpler here, not as a default pattern.
4. Compute cyclomatic complexity (rough count of independent paths) before and after, so I can see the actual improvement.
5. If any branch is unreachable or looks like dead code given the earlier conditions, flag it separately, don't silently delete it, since dead-looking code is sometimes defending against a case I haven't told you about.
Code: code
Language: language