PsiElement (PsiElement element) { if (element == null) return null; PsiElement res = element.getPrevSibling(); if (res != null) { if (res instanceof XmlProlog prolog) { if (prolog.getChildren().length > 0) { res = prolog.getLastChild(); } else { res = prolog.getPrevSibling(); } } } else { if (element.getParent() instanceof XmlProlog) { res = element.getParent().getPrevSibling(); } } return res; }