Reuse range-specific AbsorbObjects() code
Reuse range-specific AbsorbObjects() code

Also adds a check to ensure the upper index is inside array bounds.

Fixes https://sft.its.cern.ch/jira/browse/ROOT-6995

thomaskeck/root,agarciamontoro/root,lgiommi/root,abhinavmoudgil95/root,georgtroska/root,CristinaCristescu/root,davidlt/root,karies/root,georgtroska/root,veprbl/root,gbitzes/root,olifre/root,bbockelm/root,gganis/root,mhuwiler/rootauto,lgiommi/root,buuck/root,mhuwiler/rootauto,abhinavmoudgil95/root,bbockelm/root,olifre/root,veprbl/root,beniz/root,krafczyk/root,simonpf/root,beniz/root,bbockelm/root,Y--/root,lgiommi/root,BerserkerTroll/root,davidlt/root,gganis/root,gganis/root,beniz/root,satyarth934/root,lgiommi/root,root-mirror/root,georgtroska/root,pspe/root,CristinaCristescu/root,buuck/root,mhuwiler/rootauto,agarciamontoro/root,olifre/root,root-mirror/root,Y--/root,veprbl/root,georgtroska/root,krafczyk/root,olifre/root,pspe/root,BerserkerTroll/root,karies/root,gganis/root,Y--/root,karies/root,karies/root,gganis/root,olifre/root,gbitzes/root,abhinavmoudgil95/root,gganis/root,buuck/root,satyarth934/root,georgtroska/root,gbitzes/root,mhuwiler/rootauto,agarciamontoro/root,karies/root,davidlt/root,simonpf/root,georgtroska/root,satyarth934/root,sawenzel/root,lgiommi/root,mhuwiler/rootauto,krafczyk/root,thomaskeck/root,krafczyk/root,krafczyk/root,sawenzel/root,root-mirror/root,karies/root,root-mirror/root,buuck/root,Y--/root,Y--/root,agarciamontoro/root,thomaskeck/root,thomaskeck/root,zzxuanyuan/root-compressor-dummy,gbitzes/root,buuck/root,CristinaCristescu/root,root-mirror/root,pspe/root,agarciamontoro/root,veprbl/root,zzxuanyuan/root,root-mirror/root,krafczyk/root,sawenzel/root,simonpf/root,olifre/root,buuck/root,georgtroska/root,simonpf/root,Y--/root,abhinavmoudgil95/root,sawenzel/root,abhinavmoudgil95/root,CristinaCristescu/root,buuck/root,beniz/root,gbitzes/root,zzxuanyuan/root,gbitzes/root,sawenzel/root,Y--/root,zzxuanyuan/root,root-mirror/root,davidlt/root,lgiommi/root,satyarth934/root,zzxuanyuan/root,beniz/root,simonpf/root,zzxuanyuan/root,CristinaCristescu/root,georgtroska/root,beniz/root,zzxuanyuan/root,BerserkerTroll/root,BerserkerTroll/root,buuck/root,simonpf/root,pspe/root,thomaskeck/root,pspe/root,zzxuanyuan/root,thomaskeck/root,BerserkerTroll/root,lgiommi/root,bbockelm/root,simonpf/root,davidlt/root,gbitzes/root,sawenzel/root,zzxuanyuan/root-compressor-dummy,BerserkerTroll/root,davidlt/root,zzxuanyuan/root,gbitzes/root,gbitzes/root,abhinavmoudgil95/root,gganis/root,krafczyk/root,simonpf/root,gganis/root,CristinaCristescu/root,veprbl/root,mhuwiler/rootauto,zzxuanyuan/root,zzxuanyuan/root,bbockelm/root,abhinavmoudgil95/root,georgtroska/root,beniz/root,CristinaCristescu/root,pspe/root,agarciamontoro/root,georgtroska/root,sawenzel/root,buuck/root,krafczyk/root,simonpf/root,sawenzel/root,mhuwiler/rootauto,beniz/root,zzxuanyuan/root-compressor-dummy,karies/root,olifre/root,satyarth934/root,mhuwiler/rootauto,lgiommi/root,satyarth934/root,mhuwiler/rootauto,zzxuanyuan/root-compressor-dummy,agarciamontoro/root,beniz/root,veprbl/root,CristinaCristescu/root,abhinavmoudgil95/root,mhuwiler/rootauto,pspe/root,zzxuanyuan/root-compressor-dummy,sawenzel/root,gganis/root,davidlt/root,simonpf/root,CristinaCristescu/root,veprbl/root,CristinaCristescu/root,zzxuanyuan/root,davidlt/root,sawenzel/root,root-mirror/root,lgiommi/root,bbockelm/root,davidlt/root,georgtroska/root,zzxuanyuan/root-compressor-dummy,agarciamontoro/root,satyarth934/root,pspe/root,pspe/root,Y--/root,krafczyk/root,bbockelm/root,zzxuanyuan/root-compressor-dummy,lgiommi/root,krafczyk/root,satyarth934/root,karies/root,karies/root,veprbl/root,Y--/root,BerserkerTroll/root,bbockelm/root,olifre/root,sawenzel/root,Y--/root,CristinaCristescu/root,thomaskeck/root,simonpf/root,BerserkerTroll/root,veprbl/root,root-mirror/root,zzxuanyuan/root,thomaskeck/root,gganis/root,BerserkerTroll/root,veprbl/root,pspe/root,buuck/root,gbitzes/root,karies/root,abhinavmoudgil95/root,karies/root,lgiommi/root,thomaskeck/root,davidlt/root,gganis/root,Y--/root,abhinavmoudgil95/root,BerserkerTroll/root,buuck/root,beniz/root,thomaskeck/root,zzxuanyuan/root-compressor-dummy,davidlt/root,satyarth934/root,abhinavmoudgil95/root,agarciamontoro/root,agarciamontoro/root,beniz/root,zzxuanyuan/root-compressor-dummy,satyarth934/root,bbockelm/root,satyarth934/root,zzxuanyuan/root-compressor-dummy,root-mirror/root,mhuwiler/rootauto,root-mirror/root,agarciamontoro/root,olifre/root,BerserkerTroll/root,bbockelm/root,bbockelm/root,olifre/root,olifre/root,gbitzes/root,pspe/root,zzxuanyuan/root-compressor-dummy,krafczyk/root,veprbl/root