code: public static List<Class<?>> lowestClasses(Collection<Class<?>> classes) {
          final LinkedList<Class<?>> source = new LinkedList<>(classes);
          final ArrayList<Class<?>> result = new ArrayList<>(classes.size());
          while (!source.isEmpty()) {
              Class<?> lowest = source.remove();
              boolean possibleDiamond = false;
              for (Iterator<Class<?>> srcIt = source.iterator(); srcIt.hasNext();) {
                  Class<?> c = srcIt.next();
                  if (c.isAssignableFrom(lowest)) {
                      // remove higher class
                      srcIt.remove();
                  } else if (lowest.isAssignableFrom(c)) {
                      // leave lowest in source as marker for second iteration
                      possibleDiamond = true;
                      lowest = c;
                  }
              }
              if (possibleDiamond) {
                  for (Iterator<Class<?>> srcIt = source.iterator(); srcIt.hasNext();) {
                      Class<?> c = srcIt.next();
                      if (c.isAssignableFrom(lowest)) {
                          // remove higher class
                          // if lowest was found, no need to continue scanning
                          srcIt.remove();
                          if (c == lowest) break;
                      }
                  }
              }
              result.add(lowest);
          }
          result.trimToSize();
          return result;
      }
docs: Returns a subset of {@code classes}, containing all elements
  that do not have a subclass in {@code classes}.
  @param classes the classes
  @return list of lowest classes