title: iterate, find and update value in nested Map<String, ?>
body: <p>I have a YML file, which I parse to Map using yamlBeans library.
  I don't know how deep the nested map goes.
  for example:</p>
  
  <blockquote>
    <ul>
    <li>key1:
    
    <ul>
    <li>key2: value1</li>
    <li>key3: 
    
    <ul>
    <li>key4: value2</li>
    <li>key5: value3</li>
    </ul></li>
    </ul></li>
    </ul>
  </blockquote>
  
  <p>I need to find a specific value in this map, update it, and write the map back to YML file (which I know how to do).</p>
  
  <p>This is my code for updating the value, and it's working.
  <strong>However, this is only iterating twice through the nested map, and I need it to iterate it for as long as needed</strong>:</p>
  
  <pre><code>    static void updateYmlContent(Map&lt;String, ?&gt; ymlMap, String value, String... keys) {
      boolean found = false;
      for (Map.Entry entry : ymlMap.entrySet()) {
          if (entry.getKey().equals(keys[0])) {
              found = true;
              for (Map.Entry subEntry : ((Map&lt;?, ?&gt;) entry.getValue()).entrySet()) {
                  if (subEntry.getKey().equals(keys[1])) {
                      subEntry.setValue(value);
                      break;
                  } else {
                      throwKeyNotFoundException(keys[1]);
                  }
              }
              break;
          }
      }
      if (!found) {
          throwKeyNotFoundException(keys[0]);
      }
  }
  </code></pre>