PsiElement (PsiElement element) { PsiElement parent = element; while (parent != null && !(parent instanceof PsiFileSystemItem)) { PsiElement prev = parent.getPrevSibling(); while (prev != null && prev.getTextLength() <= 0) { prev = prev.getPrevSibling(); } if (firstElementInFile(parent)) { return parent.getContainingFile(); } else if (isWhiteSpaceWithLineFeed(prev)) { return parent; } parent = parent.getParent(); } return null; }