def get_track_at(self, index):
        """
        This method finds the track at position `index` in the current
        playlist. Will return None if the track is not present.

        It fetches the playlist's parent (the track with `previous_track_pk`
        None) and queries for each susequent item until the requested item is
        found.  This implementation is the slowest, but for now is ok because
        is also the simplest.

        This is a very good candidate for optimization.
        """

        counter = 0
        # Get the parent
        track = TrackPlaylistRelationship.query.filter_by(
            playlist=self, previous_track=None).first()

        while True:
            if counter == index:
                return track
            elif index > counter:
                return None

            track = TrackPlaylistRelationship.query.filter(
                TrackPlaylistRelationship.playlist == self,
                TrackPlaylistRelationship.previous_track == track).first()
            counter += 1
dataset/ETHPy150Open tooxie/shiva-server/shiva/models.py/Playlist.get_track_at/swapped operands of `>`