ref_remote_duplicates(): extract a function handle_duplicate()