code: private String uniqueKey(String key) {
          boolean generateOne = false;
  
          key = StringUtil.trimToNull(key);
          if (key == null) {
              generateOne = true;
          } else if (clauses.containsKey(key.toLowerCase())) {
              generateOne = true;
          }
  
          while (generateOne) {
              key = StringUtil.leftPad(new BigInteger(50, random).toString(32), 6).replace(" ", "0").substring(0,6);
              generateOne = clauses.containsKey(key);
          }
          return key;
      }
docs: Returns the key if it is not empty and/or not already used. If it is already used, it generates a random value for the key.