title: Deeply nested hashmaps in Java
body: <p>I have used this example to 
  <a href="https://stackoverflow.com/questions/26536599/accessing-deeply-nested-hashmaps-in-java">Accessing Deeply nested HashMaps in Java</a>
  build the data structure to store node names and properties. </p>
  
  <p>Here is the updated code:</p>
  
  <pre><code>class NestedMap {
  
  private final HashMap&lt;String, NestedMap&gt; child;
  
  private Map&lt;String, Object&gt; value = new HashMap&lt;&gt;();
  
  public NestedMap() {
      child = new HashMap&lt;&gt;();
      setValue(null);
  }
  
  public boolean hasChild(String k) {
      return this.child.containsKey(k);
  }
  
  public NestedMap getChild(String k) {
      return this.child.get(k);
  }
  
  public void makeChild(String k) {
      this.child.put(k, new NestedMap());
  }
  
  public Map&lt;String, Object&gt; getValue() {
      return value;
  }
  
  public void setValue(Map&lt;String, Object&gt; value) {
      this.value = value;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And my usage example:</p>
  
  <pre><code>    class NestedMapIllustration {
          public static void main(String[] args) {
  
          NestedMap m = new NestedMap();
  
          m.makeChild("de");
          m.getChild("de").makeChild("content");
          m.getChild("de").getChild("content").makeChild("00");
          m.getChild("de").getChild("content").makeChild("0");
          m.getChild("de").getChild("content").makeChild("1");
          m.getChild("de").getChild("content").makeChild("01");
          m.getChild("de").getChild("content").getChild("01").makeChild("fieldsets");
          m.getChild("de").getChild("content").getChild("01").getChild("fieldsets").makeChild("0");
          m.getChild("de").getChild("content").getChild("01").getChild("fieldsets").getChild("0").makeChild("fields");
          m.getChild("de").getChild("content").getChild("01").getChild("fieldsets").getChild("0").getChild("fields").makeChild("0");
          Map&lt;String, Object&gt; properties = new HashMap&lt;&gt;();
          properties.put("key", "value");
          properties.put("key2", "value");
          m.getChild("de").getChild("content").getChild("01").getChild("fieldsets").getChild("0").getChild("fields").setValue(properties);
  }
  </code></pre>
  
  <p>Instead of creating a new object each value I would like to always create a <strong>new HashMap</strong> where I can store the node properties. </p>
  
  <p>I receive my data structure by visiting nodes in the JCR datastore and extracting their values and properties. This is how my resulting data structure should look in the output yaml file:</p>
  
  <p><a href="https://i.stack.imgur.com/VV7Zg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VV7Zg.png" alt="enter image description here"></a></p>
  
  <p>How can I do that more efficiently?</p>