private static boolean statementIsLastInBlock(@NotNull PsiCodeBlock block, @NotNull PsiStatement statement) {
    for (PsiElement child = block.getLastChild(); child != null; child = child.getPrevSibling()) {
      if (child instanceof PsiStatement childStatement) {
        if (statement.equals(childStatement)) {
          return true;
        }
        if (!(statement instanceof PsiEmptyStatement)) {
          return false;
        }
      }
    }
    return false;
  }
private static boolean statementIsLastInBlock(@NotNull PsiCodeBlock block, @NotNull PsiStatement statement)