code: private static final int siblingIndex(Element element) {
  
          // The document element has index 0
          if (element.getParentNode() == element.getOwnerDocument())
              return 0;
  
          // All other elements are compared with siblings with the same name
          // TODO: How to deal with namespaces here? Omit or keep?
          else
              return $(element).parent().children(JOOX.tag(element.getTagName(), false)).get().indexOf(element);
      }
docs: Find the index among siblings of the same tag name