boolean (@NotNull PsiElement startElement) { PsiElement current = getLatestElementInCurrentScope(PsiUtil.ignoreWhiteSpaces(startElement)); MyStreamChainExistenceChecker existenceChecker = new MyStreamChainExistenceChecker(); while (current != null) { current.accept(existenceChecker); if (existenceChecker.found()) { return true; } current = toUpperLevel(current); } return false; }