<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def all_locations(self):
        '''
        Returns a queryset of all locations associated with this node and its descendants,
        excluding any duplicates.
        '''
        qs = self.assoc_locations.all()
        for node in self.get_descendants():
            qs2 = node.assoc_locations.all()
            qs = qs.union(qs2).distinct('pk')
        return qs