code: private static void computeClassHierarchy(Class<?> clazz, List<Class<?>> classes) {
          for (Class<?> current = clazz; current != null; current = current.getSuperclass()) {
              if (classes.contains(current)) {
                  return;
              }
              classes.add(current);
              for (Class<?> currentInterface : current.getInterfaces()) {
                  computeClassHierarchy(currentInterface, classes);
              }
          }
      }
docs: Get list superclasses and interfaces recursively.
  
  @param clazz The class to start the search with.
  @param classes List of classes to which to add list found super classes and interfaces.