def find_flat_segment(polygon):
    """
    Find beginning and end indexes of a horizontal section in the polygon.
    This section can be made of several consecutive segments.
    If the polygon contains several flat sections, this function only identify the first one.
    The polygon is a list of 2D coordinates (x, y)
    """
    start = -1
    end = -1
    for i, (a, b) in enumerate(zip(polygon[:-1], polygon[1:])):
        if a[1] == b[1]:
            if start < 0:
                start = i
            end = i + 1
    return [start, end]