Computing maximal invariant sets for switched nonlinear systems