It is a loop through all records. If there is a record wich exists $exists = true, but if the next record not is the same the $exists will not be reset to false because it is already true.