class InjectorUtil {

    private InjectorUtil() {}

    public static <T> T findIn(
            Class<T> type, 
            Injector injector, 
            List<Object> instances, 
            boolean required) {<FILL_FUNCTION_BODY>}
    
    public static <T> Stream<T> findAll(
            Class<T> type, 
            Injector injector, 
            List<Object> instances) {
        
        if (Injector.class.isAssignableFrom(type)) {
            @SuppressWarnings("unchecked")
            final T casted = (T) injector;
            return Stream.of(casted);
        }

        return instances.stream()
            .filter(inst -> type.isAssignableFrom(inst.getClass()))
            .map(type::cast);
    }
    
}

        
        final Optional<T> found = findAll(type, injector, instances)
            .findFirst(); // Order is important.

        if (required) {
            return found.orElseThrow(() -> 
                new IllegalArgumentException(
                    "Could not find any installed implementation of " + 
                    type.getName() + "."
                )
            );
        } else {
            return found.orElse(null);
        }
    
<no_super_class>