code: public static boolean existsKey(String keyName) throws RegistryException {
          String[] keyNameParts = keyName.split(REG_PATH_SEPARATOR_REGEX);
  
          // first part must be valid hive
          if (Hive.getHive(keyNameParts[0]) == null) {
              return false;
          }
  
          for (int i = 1; i < keyNameParts.length; i++) {
              // build path
              StringBuilder path = new StringBuilder();
              for (int j = 0; j < i; j++) {
                  path.append(keyNameParts[j]);
                  if (j < i) {
                      path.append(REG_PATH_SEPARATOR);
                  }
              }
  
              // check if next element in path exists
              List<String> subkeys = readSubkeys(path.toString());
              if (!subkeys.contains(keyNameParts[i])) {
                  return false;
              }
          }
          return true;
      }
docs: Checks if a given key exists.
  
  @param keyName Key name to check for existence.
  @return <code>true</code> if the key exists, otherwise
  <code>false</code>.
  @throws RegistryException