public static List mostSpecificTypes(List types) {
    if (types.rest() == null) {
      return (types);
    }
    { Cons cursor1 = types.theConsList;
      Cons cursor2 = null;
      Stella_Object value1 = null;
      Stella_Object value2 = null;

      while (!(cursor1 == Stella.NIL)) {
        value1 = ((Surrogate)(cursor1.value));
        if (((Surrogate)(cursor1.value)) != null) {
          cursor2 = cursor1.rest;
          loop001 : while (!(cursor2 == Stella.NIL)) {
            value2 = cursor2.value;
            if (value2 != null) {
              if (Logic.logicalSubtypeOfP(((Surrogate)(value1)), ((Surrogate)(value2)))) {
                cursor2.value = null;
              }
              else {
                if (Logic.logicalSubtypeOfP(((Surrogate)(value2)), ((Surrogate)(value1)))) {
                  cursor1.value = null;
                  break loop001;
                }
              }
            }
            cursor2 = cursor2.rest;
          }
        }
        cursor1 = cursor1.rest;
      }
    }
    types.remove(null);
    return (types);
  }