As Eric said, you can compare two objects with an equal sign - this is equivalent to comparing the GUID's for the two objects by use of the Java action.
From your question, seems like you might be trying to identify duplicate parts, so I'll use this as an example:
When you come out of your loop, you'll have a list of unique parts that you can use as you need to.
You could have a retrieve action in the loop with an xpath that looks like [id=$iteratorAllParts] which would retrieve the current loop object and store it in a variable you could use to do a comparison in the next loop. However, that would be useful if you were able to sort the parts list by an attribute like part number.
Hope that helps,
For your actual question: you could retrieve all objects, then for each objects, compare it to all other objects to see if they are equal on the set of attributes that define uniqueness (e.g. $Object1/Name = $Object2/Name and $Object1/ProductionCode = $Object2/ProductionCode). If they are duplicates, put one of the in a list and do something for this list.
To solve your general problem though: I question if you have modeled correctly: the relationship between ProductHead and ProductPart sounds like it should be a many to many relationship, since ProductParts sounds like something that could be used in many ProductHeads. If so, then this problem could be deferred to saving a ProductPart: when saving a part, retrieve a ProductPart with a different id than the current object, but equal on the set of attributes that define uniqueness. If it exists, simply do not save.
Retrieve the two lists of ProductParts over association of the 2 ProductHeads. Compare the lists with list list operation "equals". If the ProductParts are not the same objects (as Rom wrote) but created per ProductPart use a unique key :
Would they be the same exact object? If so, I think you can use equality in an expression to test this:
$Item1 = $Item2
If that doesn't work, there's a CommunityCommons java action to get an object's internal Mendix id: CommunityCommons.getGuid. You could directly compare those 2 values for equality.