code: public static Set<Class<?>> superclasses(Class<?> clazz) {
          final Queue<Class<?>> queue = new ArrayDeque<>();
          if (clazz.isInterface()) {
              queue.add(Object.class);
          }
          while (clazz != null) {
              queue.add(clazz);
              clazz = clazz.getSuperclass();
          }
          final Set<Class<?>> result = new LinkedHashSet<>();
          while (!queue.isEmpty()) {
              Class<?> c = queue.remove();
              if (result.add(c)) {
                  queue.addAll(Arrays.asList(c.getInterfaces()));
              }
          }
          return result;
      }
docs: Returns an ordered set of superclasses of {@code clazz}.
  If {@code clazz} is a class, it begins with {@code clazz}, followed by
  its superclasses and then its interfaces in breadth-first order;
  if {@code clazz} is an interface, it begins with {@code Object.class},
  followed by {@code clazz} and its super interfaces.
  @param clazz the class
  @return ordered set