void (final PsiElement element, @NotNull final List<PsiElement> result, boolean recurse) { result.add(0, element); if (doNotStep(element)) { if (!recurse) { return; } recurse = false; } final PsiElement[] children = element.getChildren(); for (final PsiElement child : children) { if (element instanceof PyStatement && child instanceof PyStatement) { continue; } collectAllElements(child, result, recurse); } }