title: Is it a bad practice to use nested HashMaps?
body: <p>Let me explain my scenario. I have some hierarchy that I need to maintain. Find below an image that shows this hierarchy. I will explain after the image.</p>
  
  <pre><code>   A
     |          +--&gt; A1.1 ---&gt; X
     |          | 
     +--&gt; A1 ---+--&gt; A1.2 ---&gt; Y
     |          |
     |          .
     +--&gt; A2    .
     .
     .
  </code></pre>
  
  <ul>
  <li>From <code>A</code> to <code>A1, A2...</code> it is a <strong>one to many</strong> relationship</li>
  <li>From <code>A1</code> to <code>A1.1, A1.2...</code> it is a <strong>one to many</strong> relationship</li>
  <li>From <code>A1.1</code> to <code>X</code> and <code>A1.2</code> to <code>Y</code> it is a <strong>one to one</strong> relationship.</li>
  </ul>
  
  <p>Initially I had designed it in such a way that it uses multiple <code>HashMap</code>s to maintain this. But then I quickly realized that updating becomes an extremely hard job. </p>
  
  <p>Having multiple <code>HashMap</code>s means that I have to handle the uniqueness across the different relationships myself. For example <code>A1.1</code> can exist within a root <code>B</code> node as well. so im having to append <code>A</code> to <code>A1.1</code> so that I can ensure uniqueness. Now if i have to modify the value <code>A</code> then I am in major trouble since I have used that to qualify all keys within <code>A</code> as <code>A_A1.1</code> </p>
  
  <p>Now i'm thinking that I can use Nested <code>HashMaps</code> for this. So the code for this becomes: </p>
  
  <pre><code>HashMap&lt;String, HashMap&lt;String, HashMap&lt;String, CustomObject&gt;&gt;&gt; _worldsBiggestHash; 
  </code></pre>
  
  <p>Is this practice ok? I do have a lot of bookkeeping to do since I'll be using nested hashes but at least CRUD and uniqueness problems handles itself. </p>
  
  <p>If this isn't okay, could anyone suggest another better structure that I can use? </p>