def consecutive(data):
    """
    Find sections of data with consecutive indices in a list of tuples with (index, value) representing candidates for
    ori and ter
    :param data: list of tuples
    :return: a list of the middle tuples of each found section of consecutives
    """
    if len(data) == 1:
        return [data[0]]
    data.sort(key=lambda x: x[0])
    ret = []
    current_seq = [data[0]]
    for i in range(1, len(data)):
        if data[i][0] == data[i - 1][0] + 1:
            current_seq.append(data[i])
        elif len(current_seq) != 0:
            current_seq.append(data[i])
            ret.append(current_seq[(len(current_seq) - 1) // 2])
            current_seq = []
        else:
            current_seq.append(data[i])
    if len(current_seq) != 0:
        ret.append(current_seq[(len(current_seq) - 1) // 2])
    return ret
