def addPathIndexFirstSegment(gridPixel, pathIndexTable, pixelTable, segmentFirstPixel):
 for yStep in xrange(gridPixel[1], (segmentFirstPixel[1] - 1), (-1)):
  if getKeyIsInPixelTableAddValue((gridPixel[0], yStep), pathIndexTable, pixelTable):
   return

def addPathIndexFirstSegment ( gridPixel , pathIndexTable , pixelTable , segmentFirstPixel ) : for yStep in xrange ( gridPixel [ 1 ] , ( segmentFirstPixel [ 1 ] - 1 ) , ( - 1 ) ) : if getKeyIsInPixelTableAddValue ( ( gridPixel [ 0 ] , yStep ) , pathIndexTable , pixelTable ) : return
add the path index of the closest segment found toward the second segment .