Replace nested switches with if.