code: def merge_and_fit(self, track, pairings):
          
  
          for (self_seg_index, track_seg_index, _) in pairings:
              self_s = self.segments[self_seg_index]
              ss_start = self_s.points[0]
              track_s = track.segments[track_seg_index]
              tt_start = track_s.points[0]
              tt_end = track_s.points[-1]
  
              d_start = ss_start.distance(tt_start)
              d_end = ss_start.distance(tt_end)
  
              if d_start > d_end:
                  track_s = track_s.copy()
                  track_s.points = list(reversed(track_s.points))
  
              self_s.merge_and_fit(track_s)
          return self
docs: Merges another track with this one, ordering the points based on a
              distance heuristic
  
          Args:
              track (:obj:`Track`): Track to merge with
              pairings
          Returns:
              :obj:`Segment`: self