Optional<String> (Map<String, List<String>> dependencies, String fruits, Map<String, String> weights) { return dependencies.get(fruits).stream().max((o1, o2) -> o1.compareTo(o2) < 0 ? -1 : o1.compareTo(o2) > 0 ? 1 : 0); }