@larine One idea could be to store the results at the end of a loop in a CSV file (append) and reload the file at the start of each loop - use that file to exclude matches already used.
Outside each inner loop you would have to reset (delete) the csv