private static void collectRequiredModulesInHierarchy(RefElement refElement, Set<? super Module> modules) {
    if (refElement instanceof RefClass) {
      processClassHierarchy(null, (RefClass)refElement, modules);
    }
    else if (refElement instanceof RefMethod refMethod) {
      UMethod uMethod = refMethod.getUastElement();
      if (uMethod != null) {
        Set<PsiClass> classes = new HashSet<>();
        processTypeHierarchy(classes, uMethod.getReturnType(), modules);
        for (UParameter parameter : uMethod.getUastParameters()) {
          processTypeHierarchy(classes, parameter.getType(), modules);
        }
        //todo thrown types
      }
    }
    else if (refElement instanceof RefField) {
      UField element = ((RefField)refElement).getUastElement();
      UClass aClass = UastContextKt.toUElement(PsiUtil.resolveClassInType(element.getType()), UClass.class);
      if (aClass != null) {
        processClassHierarchy(aClass, null, modules);
      }
    }
  }
private static void collectRequiredModulesInHierarchy(RefElement refElement, Set<? super Module> modules)