<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def distance_between(self, from_obj, to_obj, limit=2):
 """ Calculates the distance between two objects. Distance 0 means ``from_obj`` and ``to_obj`` are the same objects, 1 means ``from_obj`` has a direct connection to ``to_obj``, 2 means that one or more of ``from_obj``'s connected objects are directly connected to ``to_obj``, etc. ``limit`` limits the depth of connections traversal. Returns ``None`` if the two objects are not connected within ``limit`` distance. """

        self._validate_ctypes(from_obj, to_obj)
        
        if from_obj == to_obj:
            return 0
        
        d = 1
        pk = to_obj.pk
        qs = self.connections
        pks = qs.filter(from_pk=from_obj.pk).values_list('to_pk', flat=True)
        while limit > 0:
            if pk in pks:
                return d
            else:
                pks = qs.filter(from_pk__in=pks).values_list('pk', flat=True)
                d += 1
                limit -= 1
        
        return None