@Nullable
 private SimpleNode visit(SimpleNode simpleNode, DomElement domElement) {
   boolean validCandidate = false;
   if (simpleNode instanceof AbstractDomElementNode) {
     final DomElement nodeElement = ((AbstractDomElementNode) simpleNode).getDomElement();
     if (nodeElement != null) {
       validCandidate = !(simpleNode instanceof DomElementsGroupNode);
       if (validCandidate && nodeElement.equals(domElement)) {
         return simpleNode;
       }
       if (!(nodeElement instanceof MergedObject) && !isParent(nodeElement, domElement)) {
         return null;
       }
     }
   }
   final Object[] childElements = myBuilder.getTreeStructure().getChildElements(simpleNode);
   if (childElements.length == 0 && validCandidate) { // leaf
     return simpleNode;
   }
   for (Object child : childElements) {
     SimpleNode result = visit((SimpleNode) child, domElement);
     if (result != null) {
       return result;
     }
   }
   return validCandidate ? simpleNode : null;
 }
  private static boolean isParent(final DomElement potentialParent, final DomElement domElement) {
    DomElement currParent = domElement;
    while (currParent != null) {
      if (currParent.equals(potentialParent)) return true;

      currParent = currParent.getParent();
    }
    return false;
  }
 @Override
 @Nullable
 public Object getData(String dataId) {
   if (DATA_KEY.is(dataId)) {
     return this;
   }
   final SimpleNode simpleNode = getTree().getSelectedNode();
   if (simpleNode instanceof AbstractDomElementNode) {
     final DomElement domElement = ((AbstractDomElementNode) simpleNode).getDomElement();
     if (domElement != null && domElement.isValid()) {
       if (CommonDataKeys.NAVIGATABLE.is(dataId)) {
         final XmlElement tag = domElement.getXmlElement();
         if (tag instanceof Navigatable) {
           return tag;
         }
       }
     }
   }
   return null;
 }
 public DomModelTreeView(@NotNull DomElement rootElement) {
   this(rootElement, rootElement.getManager(), new DomModelTreeStructure(rootElement));
 }
 protected boolean isRightFile(final VirtualFile file) {
   return myRootElement == null
       || (myRootElement.isValid()
           && file.equals(DomUtil.getFile(myRootElement).getVirtualFile()));
 }