If you need to ensure that the new record is in either entity 1 or entity 2 then you can use a filter function on the lists of entity 1 and entity 2 and filter by expression to compare the fields. In this filter function the list object is the currentObject, this can be used in writing the query. Comparing 2 lists from different entities by intersecting or using contains is not an option.
Use the filter by expression in the loop over the new objects. P.S. in the example I see that you are committing objects in the loop. This is not a good practice and will have a negative effect on performance. It is better to add the objects that need a commit in a new list that you commit outside the loop.