Program: 67020
Project: 67020
Buggy source:
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.getUnmarshalNodeValue() == null) {
      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;
  }
  boolean isSelfFragment=XPathFragment.SELF_FRAGMENT.equals(anXPathFragment);
  if (isSelfFragment) {
    children.add(xPathNode);
    if (null == selfChildren) {
      selfChildren=new ArrayList();
    }
    selfChildren.add(xPathNode);
  }
 else {
    int index=children.indexOf(xPathNode);
    if (index >= 0) {
      xPathNode=(XPathNode)children.get(index);
    }
 else {
      xPathNode.setParent(this);
      if (!children.contains(xPathNode)) {
        children.add(xPathNode);
      }
      childrenMap.put(anXPathFragment,xPathNode);
    }
  }
  if (aNodeValue.isOwningNode(anXPathFragment)) {
    if (aNodeValue.isMarshalNodeValue()) {
      xPathNode.setMarshalNodeValue(aNodeValue);
    }
    if (aNodeValue.isUnmarshalNodeValue() && xPathNode.getUnmarshalNodeValue() == null) {
      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.getUnmarshalNodeValue() == null) {
      xPathNode.setUnmarshalNodeValue(aNodeValue);
    }
    xPathNode.setParent(this);
    if (aNodeValue instanceof XMLAnyAttributeMappingNodeValue) {
      setAnyAttributeNodeValue((XMLAnyAttributeMappingNodeValue)aNodeValue);
      anyAttributeNode=xPathNode;
    }
 else {
      if (!children.contains(xPathNode)) {
        children.add(xPathNode);
      }
      setAnyNode(xPathNode);
    }
    return;
  }
  boolean isSelfFragment=XPathFragment.SELF_FRAGMENT.equals(anXPathFragment);
  if (isSelfFragment) {
    children.add(xPathNode);
    if (null == selfChildren) {
      selfChildren=new ArrayList();
    }
    selfChildren.add(xPathNode);
  }
 else {
    int index=children.indexOf(xPathNode);
    if (index >= 0) {
      xPathNode=(XPathNode)children.get(index);
    }
 else {
      xPathNode.setParent(this);
      if (!children.contains(xPathNode)) {
        children.add(xPathNode);
      }
      childrenMap.put(anXPathFragment,xPathNode);
    }
  }
  if (aNodeValue.isOwningNode(anXPathFragment)) {
    if (aNodeValue.isMarshalNodeValue()) {
      xPathNode.setMarshalNodeValue(aNodeValue);
    }
    if (aNodeValue.isUnmarshalNodeValue() && xPathNode.getUnmarshalNodeValue() == null) {
      xPathNode.setUnmarshalNodeValue(aNodeValue);
    }
  }
 else {
    XPathFragment nextFragment=anXPathFragment.getNextFragment();
    xPathNode.addChild(nextFragment,aNodeValue,namespaceResolver);
  }
}