public static List<TypeRef<?>> getAllTypeArguments(TypeRef typeRef) {
    List<TypeRef<?>> types = getTypeArguments(typeRef);
    LinkedHashSet<TypeRef<?>> allTypeArguments = new LinkedHashSet<>(types);
    for (TypeRef<?> type : types) {
      allTypeArguments.addAll(getAllTypeArguments(type));
    }

    return new ArrayList<>(allTypeArguments);
  }
@Test
  public void getAllTypeArguments() {
    TypeRef<Tuple2<String, Map<String, BeanA>>> typeRef =
        new TypeRef<Tuple2<String, Map<String, BeanA>>>() {};
    List<TypeRef<?>> allTypeArguments = TypeUtils.getAllTypeArguments(typeRef);
    assertEquals(allTypeArguments.size(), 3);
    assertEquals(allTypeArguments.get(2).getRawType(), BeanA.class);
  }