public static void removeFromPermitsList(@NotNull PsiClass parent, @NotNull PsiClass exChild) {
    PsiReferenceList permitsList = parent.getPermitsList();
    if (permitsList == null) return;
    PsiJavaCodeReferenceElement[] childRefs = permitsList.getReferenceElements();
    PsiJavaCodeReferenceElement exChildRef = ContainerUtil.find(childRefs, ref -> ref.resolve() == exChild);
    if (exChildRef == null) return;
    exChildRef.delete();
    if (childRefs.length != 1) return;
    PsiModifierList modifiers = parent.getModifierList();
    if (modifiers == null) return;
    modifiers.setModifierProperty(PsiModifier.SEALED, false);
  }
public static void removeFromPermitsList(@NotNull PsiClass parent, @NotNull PsiClass exChild)