def METHOD_NAME(cmd_idx, commands, v_idx, verts_len):
    command = commands[min(cmd_idx, len(commands)-1)]
    if v_idx+1 > verts_len-1 and not command in 'LT':
        return "T"
    if v_idx+2 > verts_len-1 and not command in 'LTQS':
        return "S"
    if not command in 'LTQSC':
        return "L"
    return command