Program: 67298
Project: 67298
Buggy source:
public void addChild(XPathFragment anXPathFragment,NodeValue aNodeValue,NamespaceResolver namespaceResolver){
  if (anXPathFragment != null && namespaceResolver != null && anXPathFragment.getNamespaceURI() == null && !anXPathFragment.nameIsText()) {
    if (!anXPathFragment.isAttribute()) {
      anXPathFragment.setNamespaceURI(namespaceResolver.resolveNamespacePrefix(anXPathFragment.getPrefix()));
    }
 else     if (anXPathFragment.hasNamespace()) {
      anXPathFragment.setNamespaceURI(namespaceResolver.resolveNamespacePrefix(anXPathFragment.getPrefix()));
    }
  }
  XPathNode xPathNode=new XPathNode();
  xPathNode.setXPathFragment(anXPathFragment);
  List children;
  Map childrenMap;
  if ((anXPathFragment != null) && anXPathFragment.isAttribute()) {
    if (null == attributeChildren) {
      attributeChildren=new ArrayList();
      attributeChildrenMap=new HashMap();
    }
    children=attributeChildren;
    childrenMap=attributeChildrenMap;
  }
 else {
    if (null == nonAttributeChildren) {
      nonAttributeChildren=new ArrayList();
      nonAttributeChildrenMap=new HashMap();
    }
    children=nonAttributeChildren;
    childrenMap=nonAttributeChildrenMap;
  }
  if (null == anXPathFragment) {
    if (aNodeValue.isMarshalNodeValue()) {
      xPathNode.setMarshalNodeValue(aNodeValue);
    }
    if (aNodeValue.isUnmarshalNodeValue()) {
      xPathNode.setUnmarshalNodeValue(aNodeValue);
    }
    xPathNode.setParent(this);
    if (aNodeValue instanceof XMLAnyAttributeMappingNodeValue) {
      setAnyAttributeNodeValue((XMLAnyAttributeMappingNodeValue)aNodeValue);
      anyAttributeNode=xPathNode;
    }
 else {
      if (!children.contains(xPathNode)) {
        children.add(xPathNode);
      }
      childrenMap.put(anXPathFragment,xPathNode);
    }
    return;
  }
  int index=children.indexOf(xPathNode);
  if (index >= 0) {
    xPathNode=(XPathNode)children.get(index);
  }
 else {
    xPathNode.setParent(this);
    if (!children.contains(xPathNode)) {
      children.add(xPathNode);
    }
    if (XPathFragment.SELF_FRAGMENT.equals(anXPathFragment)) {
      if (null == selfChildren) {
        selfChildren=new ArrayList();
      }
      if (!selfChildren.contains(xPathNode)) {
        selfChildren.add(xPathNode);
      }
    }
 else {
      childrenMap.put(anXPathFragment,xPathNode);
    }
  }
  if (aNodeValue.isOwningNode(anXPathFragment)) {
    if (aNodeValue.isMarshalNodeValue()) {
      xPathNode.setMarshalNodeValue(aNodeValue);
    }
    if (aNodeValue.isUnmarshalNodeValue()) {
      xPathNode.setUnmarshalNodeValue(aNodeValue);
    }
  }
 else {
    XPathFragment nextFragment=anXPathFragment.getNextFragment();
    xPathNode.addChild(nextFragment,aNodeValue,namespaceResolver);
  }
}

Fixed version (ground truth):
public void addChild(XPathFragment anXPathFragment,NodeValue aNodeValue,NamespaceResolver namespaceResolver){
  if (null != anXPathFragment && anXPathFragment.nameIsText()) {
    if (aNodeValue.isOwningNode(anXPathFragment)) {
      XPathNode textXPathNode=new XPathNode();
      textXPathNode.setParent(this);
      textXPathNode.setXPathFragment(anXPathFragment);
      if (aNodeValue.isMarshalNodeValue()) {
        textXPathNode.setMarshalNodeValue(aNodeValue);
      }
      if (aNodeValue.isUnmarshalNodeValue()) {
        textXPathNode.setUnmarshalNodeValue(aNodeValue);
      }
      this.setTextNode(textXPathNode);
      if (null == nonAttributeChildren) {
        nonAttributeChildren=new ArrayList();
      }
      nonAttributeChildren.add(textXPathNode);
      return;
    }
  }
  if (anXPathFragment != null && namespaceResolver != null && anXPathFragment.getNamespaceURI() == null && !anXPathFragment.nameIsText()) {
    if (!anXPathFragment.isAttribute()) {
      anXPathFragment.setNamespaceURI(namespaceResolver.resolveNamespacePrefix(anXPathFragment.getPrefix()));
    }
 else     if (anXPathFragment.hasNamespace()) {
      anXPathFragment.setNamespaceURI(namespaceResolver.resolveNamespacePrefix(anXPathFragment.getPrefix()));
    }
  }
  XPathNode xPathNode=new XPathNode();
  xPathNode.setXPathFragment(anXPathFragment);
  List children;
  Map childrenMap;
  if ((anXPathFragment != null) && anXPathFragment.isAttribute()) {
    if (null == attributeChildren) {
      attributeChildren=new ArrayList();
    }
    if (null == attributeChildrenMap) {
      attributeChildrenMap=new HashMap();
    }
    children=attributeChildren;
    childrenMap=attributeChildrenMap;
  }
 else {
    if (null == nonAttributeChildren) {
      nonAttributeChildren=new ArrayList();
    }
    if (null == nonAttributeChildrenMap) {
      nonAttributeChildrenMap=new HashMap();
    }
    children=nonAttributeChildren;
    childrenMap=nonAttributeChildrenMap;
  }
  if (null == anXPathFragment) {
    if (aNodeValue.isMarshalNodeValue()) {
      xPathNode.setMarshalNodeValue(aNodeValue);
    }
    if (aNodeValue.isUnmarshalNodeValue()) {
      xPathNode.setUnmarshalNodeValue(aNodeValue);
    }
    xPathNode.setParent(this);
    if (aNodeValue instanceof XMLAnyAttributeMappingNodeValue) {
      setAnyAttributeNodeValue((XMLAnyAttributeMappingNodeValue)aNodeValue);
      anyAttributeNode=xPathNode;
    }
 else {
      if (!children.contains(xPathNode)) {
        children.add(xPathNode);
      }
      childrenMap.put(anXPathFragment,xPathNode);
    }
    return;
  }
  int index=children.indexOf(xPathNode);
  if (index >= 0) {
    xPathNode=(XPathNode)children.get(index);
  }
 else {
    xPathNode.setParent(this);
    if (!children.contains(xPathNode)) {
      children.add(xPathNode);
    }
    if (XPathFragment.SELF_FRAGMENT.equals(anXPathFragment)) {
      if (null == selfChildren) {
        selfChildren=new ArrayList();
      }
      if (!selfChildren.contains(xPathNode)) {
        selfChildren.add(xPathNode);
      }
    }
 else {
      childrenMap.put(anXPathFragment,xPathNode);
    }
  }
  if (aNodeValue.isOwningNode(anXPathFragment)) {
    if (aNodeValue.isMarshalNodeValue()) {
      xPathNode.setMarshalNodeValue(aNodeValue);
    }
    if (aNodeValue.isUnmarshalNodeValue()) {
      xPathNode.setUnmarshalNodeValue(aNodeValue);
    }
  }
 else {
    XPathFragment nextFragment=anXPathFragment.getNextFragment();
    xPathNode.addChild(nextFragment,aNodeValue,namespaceResolver);
  }
}