MAINT: Simplify the loop over the plane to be rotated when ndim>2
MAINT: Simplify the loop over the plane to be rotated when ndim>2

- Use itertools.product to generate the coordinates of the 2D slices
to be rotated when ndim > 2

See #10011.

jamestwebber/scipy,aarchiba/scipy,aarchiba/scipy,WarrenWeckesser/scipy,Eric89GXL/scipy,mdhaber/scipy,mdhaber/scipy,scipy/scipy,endolith/scipy,gertingold/scipy,mdhaber/scipy,Eric89GXL/scipy,scipy/scipy,endolith/scipy,perimosocordiae/scipy,tylerjereddy/scipy,perimosocordiae/scipy,Stefan-Endres/scipy,nmayorov/scipy,gertingold/scipy,nmayorov/scipy,ilayn/scipy,arokem/scipy,WarrenWeckesser/scipy,endolith/scipy,rgommers/scipy,e-q/scipy,pizzathief/scipy,lhilt/scipy,ilayn/scipy,endolith/scipy,aeklant/scipy,jor-/scipy,matthew-brett/scipy,aeklant/scipy,matthew-brett/scipy,arokem/scipy,scipy/scipy,perimosocordiae/scipy,anntzer/scipy,anntzer/scipy,andyfaff/scipy,jamestwebber/scipy,anntzer/scipy,ilayn/scipy,e-q/scipy,perimosocordiae/scipy,matthew-brett/scipy,matthew-brett/scipy,WarrenWeckesser/scipy,jor-/scipy,WarrenWeckesser/scipy,vigna/scipy,tylerjereddy/scipy,pizzathief/scipy,zerothi/scipy,nmayorov/scipy,mdhaber/scipy,Stefan-Endres/scipy,arokem/scipy,andyfaff/scipy,aarchiba/scipy,jamestwebber/scipy,pizzathief/scipy,gertingold/scipy,mdhaber/scipy,mdhaber/scipy,scipy/scipy,arokem/scipy,aarchiba/scipy,jor-/scipy,person142/scipy,rgommers/scipy,scipy/scipy,jamestwebber/scipy,zerothi/scipy,tylerjereddy/scipy,Eric89GXL/scipy,endolith/scipy,Stefan-Endres/scipy,aeklant/scipy,gertingold/scipy,aeklant/scipy,gertingold/scipy,grlee77/scipy,matthew-brett/scipy,rgommers/scipy,person142/scipy,perimosocordiae/scipy,zerothi/scipy,ilayn/scipy,vigna/scipy,WarrenWeckesser/scipy,andyfaff/scipy,jor-/scipy,person142/scipy,nmayorov/scipy,aeklant/scipy,Stefan-Endres/scipy,e-q/scipy,lhilt/scipy,WarrenWeckesser/scipy,Eric89GXL/scipy,lhilt/scipy,Stefan-Endres/scipy,lhilt/scipy,vigna/scipy,scipy/scipy,grlee77/scipy,anntzer/scipy,endolith/scipy,grlee77/scipy,Eric89GXL/scipy,pizzathief/scipy,lhilt/scipy,zerothi/scipy,tylerjereddy/scipy,person142/scipy,aarchiba/scipy,vigna/scipy,tylerjereddy/scipy,rgommers/scipy,Eric89GXL/scipy,zerothi/scipy,pizzathief/scipy,anntzer/scipy,e-q/scipy,grlee77/scipy,jor-/scipy,zerothi/scipy,perimosocordiae/scipy,rgommers/scipy,e-q/scipy,ilayn/scipy,person142/scipy,andyfaff/scipy,andyfaff/scipy,arokem/scipy,andyfaff/scipy,ilayn/scipy,nmayorov/scipy,anntzer/scipy,jamestwebber/scipy,grlee77/scipy,Stefan-Endres/scipy,vigna/scipy