PsiElement (PsiElement element) { PsiElement parent = element; while (parent != null && !(parent instanceof PsiFileSystemItem)) { final PsiElement next = parent.getNextSibling(); if (lastElementInFile(parent)) { return parent.getContainingFile(); } else if (isWhiteSpaceWithLineFeed(next)) { return parent; } parent = parent.getParent(); } return null; }