OptionalInt (IndexSet<?> set) { boolean seen = false; int best = 0; for (Index index : set.asList()) { int integer = index.asInteger(); if (!seen || integer < best) { seen = true; best = integer; } } return seen ? OptionalInt.of(best) : OptionalInt.empty(); }