woocommerce offtopic – Only get first product with attribute value in pre_get_posts

We’ve got a webshop with over 3000 products. Some products have the same attribute value for pa_model, as shown below.

Productid 1 - pa_model Nike 
Productid 2 - pa_model Nike
Productid 3 - pa_model Nike
Productid 4 - pa_model Nike
Productid 5 - pa_model Nike
Productid 6 - pa_model Nike
Productid 7 - pa_model Nike
Productid 8 - pa_model Adidas
Productid 9 - pa_model Adidas
Productid 10 - pa_model Adidas
Productid 11 - pa_model Adidas
Productid 12 - pa_model Puma
Productid 13 - pa_model Puma
Productid 14 - pa_model Puma
Productid 15 - pa_model Puma
Productid 16 - pa_model Puma

Inside the pre_get_posts hook we want to loop through all products from Woocommerce but only get first product with pa_model Nike and skip all products where pa_model is the same, so the outcome will be:

Productid 1 - pa_model Nike
Productid 8 - pa_model Adidas
Productid 12 - pa_model Puma

The reason why we’re trying to do this inside the pre_get_posts hook, is if we’re trying to do this outside the regular loop with a wp_query we’re getting a timeout because it exceeds the maximum time limit.

We want to use posts_per_page (15 for example) in our loop, but the ignored products with the same pa_models can’t count as a post_per_page.

$query->set('post_type', 'product');
$query->set('posts_per_page', 15);
$query->set(**TAXONOMY QUERY HERE**);