void (PsiStatement anchor, PsiStatement newStatement) { final PsiElement statementParent = anchor.getParent(); if (statementParent instanceof PsiForStatement) { final PsiElement statementGrandParent = statementParent.getParent(); statementGrandParent.addBefore(newStatement, statementParent); } else { statementParent.addAfter(newStatement, anchor); } }