code: private NodeImpl getContainingElement() {
          for (Node p = getParentNode(); p != null; p = p.getParentNode()) {
              if (p.getNodeType() == ELEMENT_NODE) {
                  return (NodeImpl) p;
              }
          }
          return null;
      }
docs: Returns the nearest ancestor element that contains this node.