The function `isPerfectlyNestedForLoops` is useful on its own and so I'm exposing it for downstream use.