void (PsiElement parent) { if (parent != null) { Stack<PsiElement> stack = new Stack<>(); if (parent instanceof PyParenthesizedExpression) stack.push(((PyParenthesizedExpression)parent).getContainedExpression()); else stack.push(parent); while (!stack.isEmpty()) { PsiElement el = stack.pop(); PsiWhiteSpace[] children = PsiTreeUtil.getChildrenOfType(el, PsiWhiteSpace.class); if (children != null) { for (PsiWhiteSpace ws : children) { if (ws.getText().contains("\\")) { ws.delete(); } } } for (PsiElement psiElement : el.getChildren()) { stack.push(psiElement); } } } }