SpringIntegration provides a ClassUtils method: findClosestMatch(Class<?> type, Set<Class<?>> candidates, boolean failOnTie)

that might be useful here if we want to actually take into account distance in the inheritance hierarchy (considering some interfaces are very generic, and so on)