public static Properties flatten(Properties config) {
        final Properties flattenProperties = new Properties();

        Collections.list(config.propertyNames()).stream()
                .forEach(
                        name -> {
                            Preconditions.checkArgument(name instanceof String);
                            flattenProperties.setProperty(
                                    (String) name, config.getProperty((String) name));
                        });

        return flattenProperties;
    }
@Test
    void testFlatten() {
        // default Properties is null
        Properties prop1 = new Properties();
        prop1.put("key1", "value1");

        // default Properties is prop1
        Properties prop2 = new Properties(prop1);
        prop2.put("key2", "value2");

        // default Properties is prop2
        Properties prop3 = new Properties(prop2);
        prop3.put("key3", "value3");

        Properties flattened = flatten(prop3);
        assertThat("value1").isEqualTo(flattened.get("key1"));
        assertThat("value2").isEqualTo(flattened.get("key2"));
        assertThat("value3").isEqualTo(flattened.get("key3"));
    }