originals-masterfiles -- remove duplicates

could someone edit the applescript “remove duplicates” in a way, that it does not delete duplicates, that are tagged as “master” or “original”? for example if there are 5 duplicates in my library in 2 of them are marked as “master” or “original” then the script would only delete the other three duplicates that are either tagged with something else or not tagged at all.

I posted an incorrect solution and removed it.

Thanks for your suggestion!
Is EF searching for duplicates within the selection or also the selection vs the whole library? if the latter is the case your solution will work. otherwise i think it will not work, since the last duplicate not tagged as master or original will stay in the library.

I withdrew the suggestion (which was to create a smart folder with all files not tagged “master” or “original”, then run the Remove Duplicates script on those files) for that very reason.