I have this map on my YamlFile class, which stores all the keys of the file on this format: String key = "firskey.secondkey.thirdkey", Object value = "Example value"

```
  private static Map<String, Object> deepkeymap;

```

Now, I want to convert my deepkeymap to a nested map that works like this: {firstkey={secondkey={thirdkey="Example value"}}}, my deepkeymap actually stores 4 keys with 4 values (the amount of keys and values will change). I have kind of accomplished this, but not totally as it only converts the last key and value of my deepkeymap, in fact, the example I've put is the output of my nested map, here is the code:

```
public void save() {
    try {
        Map<String, Object> datamap = new HashMap<String, Object>();
        for(String key : deepkeymap.keySet()) {
            Object value = deepkeymap.get(key);
            int end = key.length();
            for(int start; (start = key.lastIndexOf('.', end - 1)) != -1; end = start) {
                value = new HashMap<>(Collections.singletonMap(key.substring(start + 1, end), value));
            }
            datamap.putAll(new HashMap<>(Collections.singletonMap(key.substring(0, end), value)));
        }
        System.out.println("Datamap: "+datamap);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

```

As mentioned above, output is:

```
Datamap: {firstkey={secondkey={thirdkey="Example value"}}}

```

But it should have another 3 keys as deepkeymap contains 4 keys with their respective 4 values, I have already checked they are stored on it and no one has a null value, doing a debug on the keySet loop printing keys and values.