Conditional clustering
Based on your comments, you are looking for agglomerative hierarchical clustering.

You start with one point as its own cluster. Then iterate over pairs of clusters, merging them according to some criterion.

Typically you need to select a "cut point" after which you stop combining clusters. This is not an easy problem in general, and for the most part involves eyeballing your data until it "looks right", much like choosing K in K-means. In your case, however, you can use the external criterion you have in mind. You will need to recompute its value at every step, and then simply stop when its value passes the desired threshold.