private static void handleBranch(@NotNull Document doc,
                            @NotNull ASTNode ifStatement,
                            @NotNull ASTNode beforeBranch,
                            @Nullable ASTNode branch) {
    if (BasicJavaAstTreeUtil.is(branch, BASIC_BLOCK_STATEMENT) ||
        PsiKeyword.ELSE.equals(beforeBranch.getText()) && BasicJavaAstTreeUtil.is(branch, BASIC_IF_STATEMENT)) {
      return;
    }
    boolean transformingOneLiner = branch != null && (startLine(doc, beforeBranch) == startLine(doc, branch) ||
                                                      startCol(doc, ifStatement) < startCol(doc, branch));

    if (!transformingOneLiner) {
      doc.insertString(beforeBranch.getTextRange().getEndOffset(), "{}");
    }
    else {
      doc.insertString(beforeBranch.getTextRange().getEndOffset(), "{");
      doc.insertString(branch.getTextRange().getEndOffset() + 1, "}");
    }
  }
private static void handleBranch(@NotNull Document doc,
                            @NotNull ASTNode ifStatement,
                            @NotNull ASTNode beforeBranch,
                            @Nullable ASTNode branch)