void (PsiFile file, int offset, List<GrExpression> expressions) { final PsiElement elementAtCaret = file.findElementAt(offset); for (GrExpression expression = PsiTreeUtil.getParentOfType(elementAtCaret, GrExpression.class); expression != null; expression = PsiTreeUtil.getParentOfType(expression, GrExpression.class)) { if (MyPredicate.satisfied(expression)) { expressions.add(expression); } else if (!expressions.isEmpty()) break; } }