Having the ability to retrieve DISTINCT objects from database removes the need for looping through the object to find unique ones.
you can try this module for achieving distinct: https://appstore.home.mendix.com/link/app/81827/Enexis/ListUtils
but you have to have some understanding of XML/XSLT