String (@NotNull String programNameForLog, @NotNull Collection<String> envs) { for (String env : envs) { String val = System.getenv(env); if (val != null && new File(val).canExecute()) { debug(String.format("Using %s from %s: %s", programNameForLog, env, val)); return val; } } return null; }