How to remove specific HISM if colliding?

I wrote a function that would sort the indexes in descending order and output the order array on return. That fed a loop.

I was mass replacing painted foliage with a custom HISM instances from a class.