public static void deleteUnnecessaryStatement(PsiStatement statement) {
    CommentTracker ct = new CommentTracker();
    final PsiElement parent = statement.getParent();
    if (parent instanceof PsiIfStatement ||
        parent instanceof PsiWhileStatement ||
        parent instanceof PsiDoWhileStatement ||
        parent instanceof PsiForeachStatement ||
        parent instanceof PsiForStatement) {
      ct.replaceAndRestoreComments(statement, "{}");
    }
    else {
      ct.deleteAndRestoreComments(statement);
    }
  }
public static void deleteUnnecessaryStatement(PsiStatement statement)