As requested during review of https://github.com/openjdk/jdk/pull/20395, explore an iterative or other solution instead of 5 different cases.