My experience matches BCRider, once you hit ~24TPI or under 1mm pitch it gets more and more dicey differentiating, especially when you are dealing
with short threads such as screws or nuts with only 3-6 mm of thread length. Of course a 4mm nut is going to be really hard to evaluate.
Known screws and nuts are the easiest way to go here.
When I was wrestling with my Di2 short battery mount, the threads were standard 3Mx0.5m but the allen head socket was NOT standard. I found some potential replacement screws out of hard drive mounts. I do have a set of thread gauges.