boolean (Map<PsiCodeBlock, Collection<PsiReferenceExpression>> refs, PsiReferenceExpression psiReference, PsiCodeBlock block, Collection<? super PsiReferenceExpression> references) { for (Iterator<PsiCodeBlock> iterator = refs.keySet().iterator(); iterator.hasNext(); ) { PsiCodeBlock codeBlock = iterator.next(); if (PsiTreeUtil.isAncestor(codeBlock, block, false)) { refs.get(codeBlock).add(psiReference); return true; } else if (PsiTreeUtil.isAncestor(block, codeBlock, false)) { references.addAll(refs.get(codeBlock)); iterator.remove(); break; } } return false; }