private static boolean isInvalidPsi(@NotNull PsiElement base) {
    for (PsiElement current = base.getNextSibling(); current != null; current = current.getNextSibling()) {
      if (current instanceof PsiErrorElement) {
        return true;
      }
    }
    return base.getPrevSibling() instanceof PsiErrorElement;
  }
private static boolean isInvalidPsi(@NotNull PsiElement base)