code: protected String findBestNameForUrlNameMapping(
          CmsDbContext dbc,
          Iterator<String> nameSeq,
          CmsUUID structureId,
          String locale)
      throws CmsDataAccessException {
  
          String newName;
          boolean alreadyInUse;
          do {
              newName = nameSeq.next();
              alreadyInUse = false;
              CmsUrlNameMappingFilter filter = CmsUrlNameMappingFilter.ALL.filterName(newName);
              List<CmsUrlNameMappingEntry> entriesWithSameName = getVfsDriver(dbc).readUrlNameMappingEntries(
                  dbc,
                  false,
                  filter);
              for (CmsUrlNameMappingEntry entry : entriesWithSameName) {
                  boolean sameId = entry.getStructureId().equals(structureId);
                  if (!sameId) {
                      // name already used for other resource, or for different locale of the same resource
                      alreadyInUse = true;
                      break;
                  }
              }
          } while (alreadyInUse);
          return newName;
      }
docs: Tries to find the best name for an URL name mapping for the given structure id.<p>
  
  @param dbc the database context
  @param nameSeq the sequence of name candidates
  @param structureId the structure id to which an URL name should be mapped
  @param locale the locale for which the URL name should be mapped
  
  @return the selected URL name candidate
  
  @throws CmsDataAccessException if something goes wrong