code: public static Set<String> findFullPrefixKeys(Properties properties,
                                                 Optional<String> keyPrefix) {
      TreeSet<String> propNames = new TreeSet<>();
      for (Map.Entry<Object, Object> entry : properties.entrySet()) {
        String entryKey = entry.getKey().toString();
        if (StringUtils.startsWith(entryKey, keyPrefix.or(StringUtils.EMPTY))) {
          propNames.add(entryKey);
        }
      }
  
      Set<String> result = new HashSet<>();
      String lastKey = null;
      Iterator<String> sortedKeysIter = propNames.iterator();
      while(sortedKeysIter.hasNext()) {
        String propName = sortedKeysIter.next();
        if (null != lastKey && propName.startsWith(lastKey + ".")) {
          result.add(lastKey);
        }
        lastKey = propName;
      }
  
      return result;
    }
docs: Finds a list of properties whose keys are complete prefix of other keys. This function is
  meant to be used during conversion from Properties to typesafe Config as the latter does not
  support this scenario.
  @param     properties      the Properties collection to inspect
  @param     keyPrefix       an optional key prefix which limits which properties are inspected.