@Override
  protected void invoke(@NotNull ActionContext context, @NotNull PsiKeyword keyword, @NotNull ModPsiUpdater updater) {
    final PsiIfStatement ifStatement = (PsiIfStatement)keyword.getParent();
    final PsiIfStatement nestedIfStatement = (PsiIfStatement) ifStatement.getElseBranch();
    assert nestedIfStatement != null;

    final PsiExpression condition = ifStatement.getCondition();
    final PsiExpression nestedCondition = nestedIfStatement.getCondition();

    final PsiStatement thenBranch = ifStatement.getThenBranch();
    final PsiStatement nestedThenBranch = nestedIfStatement.getThenBranch();

    assert condition != null;
    assert nestedCondition != null;
    assert thenBranch != null;
    assert nestedThenBranch != null;

    final PsiElement conditionCopy = condition.copy();
    condition.replace(nestedCondition);
    nestedCondition.replace(conditionCopy);

    final PsiElement thenBranchCopy = thenBranch.copy();
    thenBranch.replace(nestedThenBranch);
    nestedThenBranch.replace(thenBranchCopy);
  }
@Override
  protected void invoke(@NotNull ActionContext context, @NotNull PsiKeyword keyword, @NotNull ModPsiUpdater updater)