PsiElement (@NotNull PsiElement element) { PsiElement last = element.getLastChild(); assert last != null; while (true) { PsiElement prevSibling = last.getPrevSibling(); if (prevSibling instanceof PsiWhiteSpace || prevSibling instanceof PsiErrorElement) { last = prevSibling; } else { break; } } return last; }