A final recursive function isn't better? As it would avoid test at runtime and be computed at compile time?