@Contract("_,_,false->!null")
  public static @Nullable SearchScope getHierarchyScope(@NotNull PsiClass aClass,
                                                        @NotNull SearchScope scope, 
                                                        boolean areFunctionalInheritorsExpected) {
    final List<PsiClass> classesToSearch = new ArrayList<>();
    classesToSearch.add(aClass);
    classesToSearch.addAll(ClassInheritorsSearch.search(aClass, scope, true).findAll());

    final Set<PsiClass> supers = new HashSet<>();
    for (PsiClass psiClass : classesToSearch) {
      if (areFunctionalInheritorsExpected && LambdaUtil.isFunctionalClass(psiClass)) {
        return null;
      }
      supers.addAll(InheritanceUtil.getSuperClasses(psiClass));
    }

    final List<PsiElement> elements = new ArrayList<>();
    elements.addAll(classesToSearch);
    elements.addAll(supers);

    return new LocalSearchScope(PsiUtilCore.toPsiElementArray(elements));
  }
@Contract("_,_,false->!null")
  public static @Nullable SearchScope getHierarchyScope(@NotNull PsiClass aClass,
                                                        @NotNull SearchScope scope, 
                                                        boolean areFunctionalInheritorsExpected)