You got the wrong idea about what modifies what :)
Look at this part closely:
If you isolate this part, it becomes clear that it means "inedible things that may have gotten in"(or lit. "a possibility that inedible things got in"). 可能性がある means 可能性(possibility）＋がある(exists), so it literally means "a possibility exists".
Now let's add some more to this sentence:
It is a lot more clear now that this means "due to the possibility of inedible things that got in, I decided to throw away".
Now that we got that section clear, we're only left with the first part of the sentence. When we add it we can see the appropriate context and how everything is modified: