MAINT: Simplify the logic in parallism in cKDTree.query
MAINT: Simplify the logic in parallism in cKDTree.query

Use the textbook way of static scheduling; also make use of
the inherited local scope to simplify the passing of variables.

The same function is used for non-threaded case to remove a bunch
of cdef's in the primary function -- just to reduce the duplicated
lines.

argriffing/scipy,pizzathief/scipy,haudren/scipy,anielsen001/scipy,aeklant/scipy,grlee77/scipy,jamestwebber/scipy,niknow/scipy,dominicelse/scipy,maniteja123/scipy,aeklant/scipy,perimosocordiae/scipy,zerothi/scipy,mikebenfield/scipy,gdooper/scipy,nonhermitian/scipy,woodscn/scipy,argriffing/scipy,gdooper/scipy,Gillu13/scipy,anntzer/scipy,kleskjr/scipy,pyramania/scipy,apbard/scipy,argriffing/scipy,niknow/scipy,larsmans/scipy,kleskjr/scipy,behzadnouri/scipy,befelix/scipy,apbard/scipy,Newman101/scipy,lhilt/scipy,vigna/scipy,anntzer/scipy,larsmans/scipy,person142/scipy,andyfaff/scipy,andyfaff/scipy,jamestwebber/scipy,Newman101/scipy,pschella/scipy,haudren/scipy,chatcannon/scipy,matthew-brett/scipy,bkendzior/scipy,grlee77/scipy,kalvdans/scipy,aeklant/scipy,matthew-brett/scipy,niknow/scipy,nonhermitian/scipy,behzadnouri/scipy,matthewalbani/scipy,Gillu13/scipy,Eric89GXL/scipy,jamestwebber/scipy,apbard/scipy,Eric89GXL/scipy,gertingold/scipy,jor-/scipy,person142/scipy,Newman101/scipy,endolith/scipy,matthewalbani/scipy,dominicelse/scipy,behzadnouri/scipy,aarchiba/scipy,behzadnouri/scipy,vigna/scipy,jakevdp/scipy,Stefan-Endres/scipy,nmayorov/scipy,pbrod/scipy,jjhelmus/scipy,jakevdp/scipy,argriffing/scipy,jakevdp/scipy,perimosocordiae/scipy,perimosocordiae/scipy,chatcannon/scipy,niknow/scipy,Stefan-Endres/scipy,WarrenWeckesser/scipy,mdhaber/scipy,endolith/scipy,mdhaber/scipy,Newman101/scipy,bkendzior/scipy,vigna/scipy,lhilt/scipy,chatcannon/scipy,pschella/scipy,apbard/scipy,pbrod/scipy,surhudm/scipy,aarchiba/scipy,tylerjereddy/scipy,woodscn/scipy,Newman101/scipy,anntzer/scipy,ilayn/scipy,aeklant/scipy,gdooper/scipy,jjhelmus/scipy,Gillu13/scipy,larsmans/scipy,scipy/scipy,pyramania/scipy,Gillu13/scipy,larsmans/scipy,mdhaber/scipy,scipy/scipy,Eric89GXL/scipy,anntzer/scipy,pbrod/scipy,zerothi/scipy,befelix/scipy,aarchiba/scipy,woodscn/scipy,nmayorov/scipy,maniteja123/scipy,andyfaff/scipy,argriffing/scipy,kalvdans/scipy,e-q/scipy,Shaswat27/scipy,pschella/scipy,gfyoung/scipy,maniteja123/scipy,jamestwebber/scipy,jor-/scipy,jjhelmus/scipy,perimosocordiae/scipy,gfyoung/scipy,arokem/scipy,pyramania/scipy,haudren/scipy,tylerjereddy/scipy,WarrenWeckesser/scipy,nonhermitian/scipy,kalvdans/scipy,mikebenfield/scipy,anielsen001/scipy,ilayn/scipy,gfyoung/scipy,jakevdp/scipy,matthewalbani/scipy,surhudm/scipy,gfyoung/scipy,ilayn/scipy,woodscn/scipy,maniteja123/scipy,arokem/scipy,WarrenWeckesser/scipy,e-q/scipy,pschella/scipy,e-q/scipy,rgommers/scipy,jakevdp/scipy,apbard/scipy,endolith/scipy,zerothi/scipy,matthew-brett/scipy,scipy/scipy,andyfaff/scipy,ilayn/scipy,pizzathief/scipy,WarrenWeckesser/scipy,arokem/scipy,anielsen001/scipy,vigna/scipy,chatcannon/scipy,gfyoung/scipy,sriki18/scipy,anielsen001/scipy,josephcslater/scipy,gdooper/scipy,grlee77/scipy,anielsen001/scipy,Shaswat27/scipy,jor-/scipy,jamestwebber/scipy,tylerjereddy/scipy,kleskjr/scipy,jor-/scipy,befelix/scipy,zerothi/scipy,larsmans/scipy,andyfaff/scipy,zerothi/scipy,gertingold/scipy,matthewalbani/scipy,pschella/scipy,scipy/scipy,lhilt/scipy,person142/scipy,aarchiba/scipy,kleskjr/scipy,endolith/scipy,dominicelse/scipy,niknow/scipy,Eric89GXL/scipy,ilayn/scipy,sriki18/scipy,surhudm/scipy,WarrenWeckesser/scipy,Shaswat27/scipy,bkendzior/scipy,bkendzior/scipy,woodscn/scipy,behzadnouri/scipy,kalvdans/scipy,gertingold/scipy,Stefan-Endres/scipy,mikebenfield/scipy,jor-/scipy,Shaswat27/scipy,Newman101/scipy,e-q/scipy,pyramania/scipy,gdooper/scipy,andyfaff/scipy,person142/scipy,kalvdans/scipy,matthew-brett/scipy,arokem/scipy,nonhermitian/scipy,niknow/scipy,pizzathief/scipy,vigna/scipy,befelix/scipy,josephcslater/scipy,chatcannon/scipy,nmayorov/scipy,mdhaber/scipy,jjhelmus/scipy,bkendzior/scipy,ilayn/scipy,tylerjereddy/scipy,haudren/scipy,anntzer/scipy,nmayorov/scipy,surhudm/scipy,grlee77/scipy,aeklant/scipy,rgommers/scipy,Stefan-Endres/scipy,rgommers/scipy,befelix/scipy,pbrod/scipy,argriffing/scipy,dominicelse/scipy,endolith/scipy,surhudm/scipy,matthew-brett/scipy,josephcslater/scipy,haudren/scipy,anielsen001/scipy,maniteja123/scipy,josephcslater/scipy,haudren/scipy,kleskjr/scipy,nmayorov/scipy,woodscn/scipy,arokem/scipy,dominicelse/scipy,pbrod/scipy,aarchiba/scipy,pizzathief/scipy,Stefan-Endres/scipy,lhilt/scipy,grlee77/scipy,Gillu13/scipy,jjhelmus/scipy,maniteja123/scipy,chatcannon/scipy,endolith/scipy,sriki18/scipy,tylerjereddy/scipy,rgommers/scipy,larsmans/scipy,pyramania/scipy,pbrod/scipy,rgommers/scipy,behzadnouri/scipy,mdhaber/scipy,sriki18/scipy,WarrenWeckesser/scipy,gertingold/scipy,pizzathief/scipy,nonhermitian/scipy,josephcslater/scipy,e-q/scipy,zerothi/scipy,sriki18/scipy,mdhaber/scipy,gertingold/scipy,perimosocordiae/scipy,Stefan-Endres/scipy,person142/scipy,Eric89GXL/scipy,scipy/scipy,Shaswat27/scipy,scipy/scipy,Shaswat27/scipy,surhudm/scipy,mikebenfield/scipy,matthewalbani/scipy,Gillu13/scipy,perimosocordiae/scipy,sriki18/scipy,mikebenfield/scipy,Eric89GXL/scipy,anntzer/scipy,lhilt/scipy,kleskjr/scipy