@Nullable
  protected static <T extends PsiNamedElement> T restoreElementInternal(@NotNull PsiElement parent,
                                                              String name,
                                                              int index,
                                                              @NotNull Class<T> hisClass)
  {
    PsiElement[] children = parent.getChildren();

    for (PsiElement child : children) {
      if (ReflectionUtil.isAssignable(hisClass, child.getClass())) {
        T namedChild = hisClass.cast(child);
        final String childName = namedChild.getName();

        if (Objects.equals(name, childName)) {
          if (index == 0) {
            return namedChild;
          }
          index--;
        }
      }
    }

    return null;
  }
@Nullable
  protected static <T extends PsiNamedElement> T restoreElementInternal(@NotNull PsiElement parent,
                                                              String name,
                                                              int index,
                                                              @NotNull Class<T> hisClass)