### Question:
NestedMaps { @SuppressWarnings("unchecked") public static <T> Optional<T> getValue(Map<String, Object> data, String path) { if (!path.contains(".")) { return Optional.ofNullable((T) data.get(path)); } int index = path.indexOf("."); String key = path.substring(0, index); if (data.get(key) instanceof Map) { return getValue((Map<String, Object>) data.get(key), path.substring(index + 1)); } else { return Optional.empty(); } } private  NestedMaps(); @SuppressWarnings("unchecked") static Optional<T> getValue(Map<String, Object> data, String path); static Map<String, T> deepMerge(final Stream<Map<String, T>> mapStream); @SuppressWarnings({ "rawtypes", "unchecked" }) static void deepMerge(Map left, Map right); static Map<String, Object> unflatten(Map<String, Object> flattened);  }### Answer:
@Test void testGetValue() { assertThat(NestedMaps.getValue(NESTED_MAP_1, "foo.baz")).hasValue("baz"); assertThat(NestedMaps.getValue(NESTED_MAP_1, "foo.foo")).hasValue("bar"); assertThat(NestedMaps.getValue(NESTED_MAP_1, "foo.bar.baz")).isEmpty(); assertThat(NestedMaps.getValue(NESTED_MAP_1, "baa")).isEmpty(); assertThat(NestedMaps.getValue(NESTED_MAP_1, "foo.bar.foo")).hasValue("bar"); assertThat(NestedMaps.getValue(NESTED_MAP_1, "foo.bar.bar")).hasValue("foo"); assertThat(NestedMaps.getValue(NESTED_MAP_1, "bar.foo.bar.foo")).hasValue("baz"); assertThat((Collection) NestedMaps.getValue(NESTED_MAP_1, "list").get()).containsExactly("foo", "bar"); assertThat(NestedMaps.getValue(NESTED_MAP_1, "bar.foo.bar")).hasValueSatisfying(v -> { assertThat(v).isInstanceOf(Map.class); assertThat((Map) v).hasFieldOrPropertyWithValue("foo", "baz"); }); }