How to get a list of unique related entries from within a related entries loop
How about this?

{% set uniqueLocations = craft.entries.section('locations').relatedTo(mockExams).all() %}

{% for location in uniqueLocations %}
  {{ location.title }}&lt;br /&gt;
  {{ location.address }}
{% endfor %}