def METHOD_NAME(id):
    ind = id // num_levels
    mod = id % num_levels
    if ind % 2 == 1:  # odd
        if mod == (num_levels - 1):
            last = -1
        else:
            last = (ind - 1) * num_levels + (
                num_levels - 1 - mod - 1)
    else:  # even
        if mod == 0:
            last = -1
        else:
            last = (ind - 1) * num_levels + (
                num_levels - 1 - mod + 1)
    return last