PsiElement () { if (e == null || e == scope) return null; PsiElement prev = e.getPrevSibling(); if (prev != null) { return e = PsiTreeUtil.getDeepestLast(prev); } else { PsiElement parent = e.getParent(); return e = parent == scope || parent instanceof PsiFile ? null : parent; } }