XmlFile (XmlTag tag) { while (true) { final PsiElement parentTag = PhysicalDomParentStrategy.getParentTagCandidate(tag); if (!(parentTag instanceof XmlTag)) { return (XmlFile)tag.getContainingFile(); } tag = (XmlTag)parentTag; } }