@Nullable
 public ElementStub getElementStub(String name, int index) {
   List<DomStub> stubs = getChildrenStubs();
   int i = 0;
   for (DomStub stub : stubs) {
     if (stub instanceof ElementStub && name.equals(stub.getName()) && i++ == index) {
       return (ElementStub) stub;
     }
   }
   return null;
 }
  @Nullable
  public AttributeStub getAttributeStub(final XmlName name) {
    final List<DomStub> stubs = getChildrenStubs();
    if (stubs.isEmpty()) {
      return null;
    }

    //noinspection ForLoopReplaceableByForEach
    for (int i = 0, size = stubs.size(); i < size; i++) {
      final DomStub stub = stubs.get(i);
      if (stub instanceof AttributeStub && stub.getName().equals(name.getLocalName())) {
        return (AttributeStub) stub;
      }
    }
    return null;
  }
  public List<DomStub> getChildrenByName(final CharSequence name, @Nullable final String nsKey) {
    final List<DomStub> stubs = getChildrenStubs();
    if (stubs.isEmpty()) {
      return Collections.emptyList();
    }

    final String s = nsKey == null ? "" : nsKey;
    final List<DomStub> result = new SmartList<DomStub>();
    //noinspection ForLoopReplaceableByForEach
    for (int i = 0, size = stubs.size(); i < size; i++) {
      final DomStub stub = stubs.get(i);
      if (XmlUtil.getLocalName(stub.getName()).equals(name)
          && Comparing.equal(s, stub.getNamespaceKey())) {
        result.add(stub);
      }
    }
    return result;
  }
 public int getChildIndex(DomStub child) {
   List<DomStub> stubs =
       getChildrenByName(XmlUtil.getLocalName(child.getName()), child.getNamespaceKey());
   return stubs.indexOf(child);
 }