code: private static void getAllInterfaces(Class<?> cls, Collection<Class<?>> interfacesFound) {
          while (cls != null) {
              Class<?>[] interfaces = cls.getInterfaces();
  
              for (int i = 0; i < interfaces.length; i++) {
                  interfacesFound.add(interfaces[i]);
                  getAllInterfaces(interfaces[i], interfacesFound);
              }
  
              cls = cls.getSuperclass();
           }
       }
docs: Get the interfaces for the specified class.
  
  @param cls  the class to look up, may be <code>null</code>
  @param interfacesFound the <code>Set</code> of interfaces for the class