class PropertiesExt {

    public static Map<String, Set<String>> splitNames(Collection<String> names, int rootSegments) {
        // Split nested field names
        Map<String, Set<String>> topNames = new HashMap<>();
        names.forEach(n -> {
            Pair<String, String> parts = split(n, rootSegments);
            if (parts == null) {
                topNames.put(n, null);
            } else {
                Set<String> nested = topNames.get(parts.getLeft());
                if (nested == null) {
                    nested = new HashSet<>();
                    topNames.put(parts.getLeft(), nested);
                }
                nested.add(parts.getRight());
            }
        });
        return topNames;
    }

    private  PropertiesExt();

}