Program: 112316
Project: 112316
Buggy source:
private Map<RuntimeChildDeclaredExtensionDefinition,String> scanForExtensions(Profile theProfile,BaseRuntimeElementDefinition<?> def){
  BaseRuntimeElementCompositeDefinition<?> cdef=((BaseRuntimeElementCompositeDefinition<?>)def);
  Map<RuntimeChildDeclaredExtensionDefinition,String> extensionDefToCode=new HashMap<RuntimeChildDeclaredExtensionDefinition,String>();
  for (  RuntimeChildDeclaredExtensionDefinition nextChild : cdef.getExtensions()) {
    if (extensionDefToCode.containsKey(nextChild)) {
      continue;
    }
    if (nextChild.isDefinedLocally() == false) {
      continue;
    }
    ExtensionDefn defn=theProfile.addExtensionDefn();
    String code=null;
    if (nextChild.getExtensionUrl().contains("String_Node_Str") && !nextChild.getExtensionUrl().endsWith("String_Node_Str")) {
      code=nextChild.getExtensionUrl().substring(nextChild.getExtensionUrl().indexOf('#') + 1);
    }
 else {
      throw new ConfigurationException("String_Node_Str" + nextChild.getExtensionUrl());
    }
    defn.setCode(code);
    if (extensionDefToCode.values().contains(code)) {
      throw new IllegalStateException("String_Node_Str" + code);
    }
    extensionDefToCode.put(nextChild,code);
    if (nextChild.getChildType() != null && IPrimitiveDatatype.class.isAssignableFrom(nextChild.getChildType())) {
      RuntimePrimitiveDatatypeDefinition pdef=(RuntimePrimitiveDatatypeDefinition)nextChild.getSingleChildOrThrow();
      defn.getDefinition().addType().setCode(DataTypeEnum.VALUESET_BINDER.fromCodeString(pdef.getName()));
    }
 else     if (nextChild.getChildType() != null && ICompositeDatatype.class.isAssignableFrom(nextChild.getChildType())) {
      RuntimeCompositeDatatypeDefinition pdef=(RuntimeCompositeDatatypeDefinition)nextChild.getSingleChildOrThrow();
      defn.getDefinition().addType().setCode(DataTypeEnum.VALUESET_BINDER.fromCodeString(pdef.getName()));
    }
 else {
      RuntimeResourceBlockDefinition pdef=(RuntimeResourceBlockDefinition)nextChild.getSingleChildOrThrow();
      scanForExtensions(theProfile,pdef);
      for (      RuntimeChildDeclaredExtensionDefinition nextChildExt : pdef.getExtensions()) {
        StructureElementDefinitionType type=defn.getDefinition().addType();
        type.setCode(DataTypeEnum.EXTENSION);
        type.setProfile("String_Node_Str" + extensionDefToCode.get(nextChildExt));
      }
    }
  }
  return extensionDefToCode;
}

Fixed version (ground truth):
private Map<RuntimeChildDeclaredExtensionDefinition,String> scanForExtensions(Profile theProfile,BaseRuntimeElementDefinition<?> def,Map<RuntimeChildDeclaredExtensionDefinition,String> theExtensionDefToCode){
  BaseRuntimeElementCompositeDefinition<?> cdef=((BaseRuntimeElementCompositeDefinition<?>)def);
  for (  RuntimeChildDeclaredExtensionDefinition nextChild : cdef.getExtensions()) {
    if (theExtensionDefToCode.containsKey(nextChild)) {
      continue;
    }
    if (nextChild.isDefinedLocally() == false) {
      continue;
    }
    ExtensionDefn defn=theProfile.addExtensionDefn();
    String code=null;
    if (nextChild.getExtensionUrl().contains("String_Node_Str") && !nextChild.getExtensionUrl().endsWith("String_Node_Str")) {
      code=nextChild.getExtensionUrl().substring(nextChild.getExtensionUrl().indexOf('#') + 1);
    }
 else {
      throw new ConfigurationException("String_Node_Str" + nextChild.getExtensionUrl());
    }
    defn.setCode(code);
    if (theExtensionDefToCode.values().contains(code)) {
      throw new IllegalStateException("String_Node_Str" + code);
    }
    theExtensionDefToCode.put(nextChild,code);
    if (nextChild.getChildType() != null && IPrimitiveDatatype.class.isAssignableFrom(nextChild.getChildType())) {
      RuntimePrimitiveDatatypeDefinition pdef=(RuntimePrimitiveDatatypeDefinition)nextChild.getSingleChildOrThrow();
      defn.getDefinition().addType().setCode(DataTypeEnum.VALUESET_BINDER.fromCodeString(pdef.getName()));
    }
 else     if (nextChild.getChildType() != null && ICompositeDatatype.class.isAssignableFrom(nextChild.getChildType())) {
      RuntimeCompositeDatatypeDefinition pdef=(RuntimeCompositeDatatypeDefinition)nextChild.getSingleChildOrThrow();
      defn.getDefinition().addType().setCode(DataTypeEnum.VALUESET_BINDER.fromCodeString(pdef.getName()));
    }
 else {
      RuntimeResourceBlockDefinition pdef=(RuntimeResourceBlockDefinition)nextChild.getSingleChildOrThrow();
      scanForExtensions(theProfile,pdef,theExtensionDefToCode);
      for (      RuntimeChildDeclaredExtensionDefinition nextChildExt : pdef.getExtensions()) {
        StructureElementDefinitionType type=defn.getDefinition().addType();
        type.setCode(DataTypeEnum.EXTENSION);
        type.setProfile("String_Node_Str" + theExtensionDefToCode.get(nextChildExt));
      }
    }
  }
  return theExtensionDefToCode;
}