def METHOD_NAME(line, end):
    """Reverse line if necessary to ensure that it ends near end."""
    line_start = ShapelyPoint(*line.coords[0])
    line_end = ShapelyPoint(*line.coords[-1])
    if line_end.distance(end) < line_start.distance(end):
        return line
    else:
        return LineString(line.coords[::-1])