How to use Loops to filter out an array

You should really just store a map of booleans + a string named after the “parent classes”. Each item will contain a string for the name of the class it belongs to. When the item is overlapped get the string name, compare it to the MAP data and see if the boolean of that string pair is true or false. If false, you don’t have it, you can pick it up, then set to true. If true, you are already holding an item of that class and you prevent pick up. When you use or drop the item, go back to the MAP and set the boolean to false. This way, you can only have one item of each class at a time.