Program: 63680
Project: 63680
Buggy source:
private NodeValue getNodeValueForValue(Object value){
  if (value == null) {
    Iterator<NodeValue> nodeValues=fieldToNodeValues.values().iterator();
    while (nodeValues.hasNext()) {
      XMLChoiceCollectionMappingUnmarshalNodeValue unmarshalNodeValue=(XMLChoiceCollectionMappingUnmarshalNodeValue)nodeValues.next();
      NodeValue nextNodeValue=unmarshalNodeValue.getChoiceElementMarshalNodeValue();
      if (nextNodeValue instanceof MappingNodeValue) {
        Mapping nextMapping=((MappingNodeValue)nextNodeValue).getMapping();
        if (nextMapping.isAbstractCompositeCollectionMapping()) {
          if (((CompositeCollectionMapping)nextMapping).getNullPolicy().isNullRepresentedByXsiNil()) {
            return unmarshalNodeValue;
          }
        }
 else         if (nextMapping.isAbstractCompositeDirectCollectionMapping()) {
          if (((DirectCollectionMapping)nextMapping).getNullPolicy().isNullRepresentedByXsiNil()) {
            return unmarshalNodeValue;
          }
        }
 else         if (nextMapping instanceof BinaryDataCollectionMapping) {
          if (((BinaryDataCollectionMapping)nextMapping).getNullPolicy().isNullRepresentedByXsiNil()) {
            return unmarshalNodeValue;
          }
        }
      }
    }
    return null;
  }
  Field associatedField=null;
  NodeValue nodeValue=null;
  if (value instanceof Root) {
    Root rootValue=(Root)value;
    String localName=rootValue.getLocalName();
    String namespaceUri=rootValue.getNamespaceURI();
    Object fieldValue=rootValue.getObject();
    associatedField=getFieldForName(localName,namespaceUri);
    if (associatedField == null) {
      Class theClass=fieldValue.getClass();
      while (associatedField == null) {
        associatedField=(Field)xmlChoiceCollectionMapping.getClassToFieldMappings().get(theClass);
        if (theClass.getSuperclass() != null) {
          theClass=theClass.getSuperclass();
        }
 else {
          break;
        }
      }
    }
    if (associatedField != null) {
      nodeValue=this.fieldToNodeValues.get(associatedField);
    }
  }
 else {
    Class theClass=value.getClass();
    while (associatedField == null) {
      associatedField=(Field)xmlChoiceCollectionMapping.getClassToFieldMappings().get(theClass);
      nodeValue=classToNodeValues.get(theClass);
      if (theClass.getSuperclass() != null) {
        theClass=theClass.getSuperclass();
      }
 else {
        break;
      }
    }
  }
  if (associatedField == null) {
    List<Field> sourceFields=null;
    Class theClass=value.getClass();
    while (theClass != null) {
      sourceFields=(List<Field>)xmlChoiceCollectionMapping.getClassToSourceFieldsMappings().get(theClass);
      if (sourceFields != null) {
        break;
      }
      theClass=theClass.getSuperclass();
    }
    if (sourceFields != null) {
      associatedField=sourceFields.get(0);
      nodeValue=fieldToNodeValues.get(associatedField);
    }
  }
  if (nodeValue != null) {
    return nodeValue;
  }
  if (associatedField != null) {
    return fieldToNodeValues.get(associatedField);
  }
  if (xmlChoiceCollectionMapping.isMixedContent() && value instanceof String) {
    return this;
  }
  return null;
}

Fixed version (ground truth):
private NodeValue getNodeValueForValue(Object value){
  if (value == null) {
    Iterator<NodeValue> nodeValues=fieldToNodeValues.values().iterator();
    while (nodeValues.hasNext()) {
      XMLChoiceCollectionMappingUnmarshalNodeValue unmarshalNodeValue=(XMLChoiceCollectionMappingUnmarshalNodeValue)nodeValues.next();
      NodeValue nextNodeValue=unmarshalNodeValue.getChoiceElementMarshalNodeValue();
      if (nextNodeValue instanceof MappingNodeValue) {
        Mapping nextMapping=((MappingNodeValue)nextNodeValue).getMapping();
        if (nextMapping.isAbstractCompositeCollectionMapping()) {
          if (((CompositeCollectionMapping)nextMapping).getNullPolicy().isNullRepresentedByXsiNil()) {
            return unmarshalNodeValue;
          }
        }
 else         if (nextMapping.isAbstractCompositeDirectCollectionMapping()) {
          if (((DirectCollectionMapping)nextMapping).getNullPolicy().isNullRepresentedByXsiNil()) {
            return unmarshalNodeValue;
          }
        }
 else         if (nextMapping instanceof BinaryDataCollectionMapping) {
          if (((BinaryDataCollectionMapping)nextMapping).getNullPolicy().isNullRepresentedByXsiNil()) {
            return unmarshalNodeValue;
          }
        }
      }
    }
    return null;
  }
  Field associatedField=null;
  NodeValue nodeValue=null;
  if (value instanceof Root) {
    Root rootValue=(Root)value;
    String localName=rootValue.getLocalName();
    String namespaceUri=rootValue.getNamespaceURI();
    Object fieldValue=rootValue.getObject();
    associatedField=getFieldForName(localName,namespaceUri);
    if (associatedField == null) {
      Class theClass=fieldValue.getClass();
      while (associatedField == null) {
        associatedField=(Field)xmlChoiceCollectionMapping.getClassToFieldMappings().get(theClass);
        if (theClass.getSuperclass() != null) {
          theClass=theClass.getSuperclass();
        }
 else {
          break;
        }
      }
    }
    if (associatedField != null) {
      nodeValue=this.fieldToNodeValues.get(associatedField);
    }
  }
 else {
    Class theClass=value.getClass();
    while (associatedField == null) {
      associatedField=(Field)xmlChoiceCollectionMapping.getClassToFieldMappings().get(theClass);
      nodeValue=classToNodeValues.get(theClass);
      if (theClass.getSuperclass() != null) {
        theClass=theClass.getSuperclass();
      }
 else {
        break;
      }
    }
  }
  if (associatedField == null) {
    List<Field> sourceFields=null;
    Class theClass=value.getClass();
    while (theClass != null) {
      sourceFields=(List<Field>)xmlChoiceCollectionMapping.getClassToSourceFieldsMappings().get(theClass);
      if (sourceFields != null) {
        break;
      }
      theClass=theClass.getSuperclass();
    }
    if (sourceFields != null) {
      associatedField=sourceFields.get(0);
      nodeValue=fieldToNodeValues.get(associatedField);
    }
  }
  if (nodeValue != null) {
    return nodeValue;
  }
  if (associatedField != null) {
    return fieldToNodeValues.get(associatedField);
  }
  if (xmlChoiceCollectionMapping.isMixedContent() && value instanceof String) {
    return this;
  }
  if (xmlChoiceCollectionMapping.isAny()) {
    return anyNodeValue;
  }
  return null;
}