def _closest(e, l):
    """ Finds the element and its index, closest to e, in l """
    closest = None
    closest_idx = None
    min_diff = float('inf')
    for i, j in enumerate(l):
        diff = abs(j - e)
        if diff < min_diff:
            min_diff = abs(j - e)
            closest = j
            closest_idx = i
    return closest, closest_idx