public static Map<String, Object> flatten(Map<String, Object> originalMap, String parentKey, String separator) {
        final Map<String, Object> result = new HashMap<>();
        for (Map.Entry<String, Object> entry : originalMap.entrySet()) {
            final String key = parentKey.isEmpty() ? entry.getKey() : parentKey + separator + entry.getKey();
            final Object value = entry.getValue();
            if (value instanceof Map) {
                @SuppressWarnings("unchecked")
                final Map<String, Object> valueMap = (Map<String, Object>) value;
                result.putAll(flatten(valueMap, key, separator));
            } else {
                result.put(key, value);
            }
        }
        return result;
    }
@Test
    public void flattenAddsParentKey() throws Exception {
        final Map<String, Object> map = ImmutableMap.of(
                "map", ImmutableMap.of(
                        "foo", "bar",
                        "baz", "qux"));
        final Map<String, Object> expected = ImmutableMap.of(
                "map_foo", "bar",
                "map_baz", "qux");
        assertThat(MapUtils.flatten(map, "", "_")).isEqualTo(expected);
    }