Program: 12521
Project: 12521
Buggy source:
/** 
 * @param newTopLevel
 * @param instancesMap
 * @param typeName
 * @param maps
 * @throws SBOLValidationException if either of the following SBOL validation rules was violated:10202, 10220. 
 */
@SafeVarargs private final <TL extends TopLevel>void addTopLevel(TL newTopLevel,Map<URI,TL> instancesMap,String typeName,Map<URI,? extends Identified>... maps) throws SBOLValidationException {
  boolean childrenCompliant=true;
  try {
    newTopLevel.checkDescendantsURIcompliance();
  }
 catch (  SBOLValidationException e) {
    childrenCompliant=false;
  }
  if (compliant && childrenCompliant) {
    URI persistentId=URI.create(extractPersistentId(newTopLevel.getIdentity()));
    if (keyExistsInAnyMap(persistentId,maps))     throw new SBOLValidationException("String_Node_Str",newTopLevel);
    if (instancesMap.containsKey(newTopLevel.getIdentity()))     throw new SBOLValidationException("String_Node_Str",newTopLevel);
    String prefix=extractURIprefix(persistentId);
    while (prefix != null) {
      if (keyExistsInAnyMap(URI.create(prefix),maps))       throw new SBOLValidationException("String_Node_Str",newTopLevel);
      if (instancesMap.containsKey(URI.create(prefix)))       throw new SBOLValidationException("String_Node_Str",newTopLevel);
      prefix=extractURIprefix(URI.create(prefix));
    }
    if (prefixes.contains(persistentId.toString())) {
      throw new IllegalArgumentException("String_Node_Str" + persistentId.toString() + "String_Node_Str");
    }
    prefix=extractURIprefix(persistentId);
    while (prefix != null) {
      prefixes.add(prefix);
      prefix=extractURIprefix(URI.create(prefix));
    }
    instancesMap.put(newTopLevel.getIdentity(),newTopLevel);
    Identified latest=instancesMap.get(persistentId);
    if (latest == null) {
      instancesMap.put(persistentId,newTopLevel);
    }
 else {
      if (isFirstVersionNewer(extractVersion(newTopLevel.getIdentity()),extractVersion(latest.getIdentity()))) {
        instancesMap.put(persistentId,newTopLevel);
      }
    }
  }
 else {
    if (keyExistsInAnyMap(newTopLevel.getIdentity()))     throw new SBOLValidationException("String_Node_Str",newTopLevel);
    if (instancesMap.containsKey(newTopLevel.getIdentity()))     throw new SBOLValidationException("String_Node_Str",newTopLevel);
    instancesMap.put(newTopLevel.getIdentity(),newTopLevel);
    if (newTopLevel.isSetPersistentIdentity()) {
      Identified latest=instancesMap.get(newTopLevel.getPersistentIdentity());
      if (latest == null) {
        instancesMap.put(newTopLevel.getPersistentIdentity(),newTopLevel);
      }
 else {
        if (isFirstVersionNewer(extractVersion(newTopLevel.getIdentity()),extractVersion(latest.getIdentity()))) {
          instancesMap.put(newTopLevel.getPersistentIdentity(),newTopLevel);
        }
      }
    }
  }
  newTopLevel.setSBOLDocument(this);
}

Fixed version (ground truth):
/** 
 * @param newTopLevel
 * @param instancesMap
 * @param typeName
 * @param maps
 * @throws SBOLValidationException if either of the following SBOL validation rules was violated:10202, 10220. 
 */
@SafeVarargs private final <TL extends TopLevel>void addTopLevel(TL newTopLevel,Map<URI,TL> instancesMap,String typeName,Map<URI,? extends Identified>... maps) throws SBOLValidationException {
  boolean childrenCompliant=true;
  try {
    URIcompliance.isURIcompliant(newTopLevel);
  }
 catch (  SBOLValidationException e) {
    childrenCompliant=false;
  }
  if (compliant && childrenCompliant) {
    URI persistentId=URI.create(extractPersistentId(newTopLevel.getIdentity()));
    if (keyExistsInAnyMap(persistentId,maps))     throw new SBOLValidationException("String_Node_Str",newTopLevel);
    if (instancesMap.containsKey(newTopLevel.getIdentity()))     throw new SBOLValidationException("String_Node_Str",newTopLevel);
    String prefix=extractURIprefix(persistentId);
    while (prefix != null) {
      if (keyExistsInAnyMap(URI.create(prefix),maps))       throw new SBOLValidationException("String_Node_Str",newTopLevel);
      if (instancesMap.containsKey(URI.create(prefix)))       throw new SBOLValidationException("String_Node_Str",newTopLevel);
      prefix=extractURIprefix(URI.create(prefix));
    }
    if (prefixes.contains(persistentId.toString())) {
      throw new IllegalArgumentException("String_Node_Str" + persistentId.toString() + "String_Node_Str");
    }
    prefix=extractURIprefix(persistentId);
    while (prefix != null) {
      prefixes.add(prefix);
      prefix=extractURIprefix(URI.create(prefix));
    }
    instancesMap.put(newTopLevel.getIdentity(),newTopLevel);
    Identified latest=instancesMap.get(persistentId);
    if (latest == null) {
      instancesMap.put(persistentId,newTopLevel);
    }
 else {
      if (isFirstVersionNewer(extractVersion(newTopLevel.getIdentity()),extractVersion(latest.getIdentity()))) {
        instancesMap.put(persistentId,newTopLevel);
      }
    }
  }
 else {
    if (keyExistsInAnyMap(newTopLevel.getIdentity()))     throw new SBOLValidationException("String_Node_Str",newTopLevel);
    if (instancesMap.containsKey(newTopLevel.getIdentity()))     throw new SBOLValidationException("String_Node_Str",newTopLevel);
    instancesMap.put(newTopLevel.getIdentity(),newTopLevel);
    if (newTopLevel.isSetPersistentIdentity()) {
      Identified latest=instancesMap.get(newTopLevel.getPersistentIdentity());
      if (latest == null) {
        instancesMap.put(newTopLevel.getPersistentIdentity(),newTopLevel);
      }
 else {
        if (isFirstVersionNewer(extractVersion(newTopLevel.getIdentity()),extractVersion(latest.getIdentity()))) {
          instancesMap.put(newTopLevel.getPersistentIdentity(),newTopLevel);
        }
      }
    }
  }
  newTopLevel.setSBOLDocument(this);
}