title: Dynamic nested dictionaries
body: <p>Just to begin I know there are a couple similarly-titled questions on here, but none are explained quite this way nor is the problem scope the same.</p>
  
  <p>I want to add nested dictionary entries dynamically.</p>
  
  <p>The use case is thus:
  I have a python script that is monitoring the network. A dictionary is created for each observed IP protocol (tcp, udp, icmp) that is observed. Then a sub-dictionary is created with a key that is the destination port (if one exists) for each of these IP protocols (80, 443, etc.) (note it doesn't matter whether it sees the server port as the source or destination, but normally servers are the destination so I picked HTTP and HTTPS as examples). For each of these destination ports a key is created corresponding to the server IP (e.g., the IP for www.google.com). And then another dictionary with the timestamp the session was first observed as the key and the data/value for the key being the client's IP.</p>
  
  <p>However, I want need this to be populated as time goes on since I won't have the data before execution nor at initialization.</p>
  
  <p>The output would look something akin to:</p>
  
  <pre><code>{  'icmp' :
     {  'echo-request' :
         {  '&lt;ip_of_www.google.com&gt;' :
             {   '&lt;timestamp&gt;' : &lt;some_client_ip&gt; }
         }
        'echo-reply' :
         {  '&lt;ip_of_www.google.com&gt;' :
             {   '&lt;timestamp&gt;' : &lt;some_client_ip&gt; }
         }
     }
     'tcp' :
     {
        '80' 
         {  '&lt;ip_of_www.google.com&gt;' :
             {   '&lt;timestamp&gt;' : &lt;some_client_ip&gt; }
             {   '&lt;timestamp&gt;' : &lt;some_client_ip&gt; }
         }
        '443' 
         {  '&lt;ip_of_encrypted.google.com&gt;' :
             {   '&lt;timestamp&gt;' : &lt;some_client_ip&gt; }
             {   '&lt;timestamp&gt;' : &lt;some_client_ip&gt; }
             {   '&lt;timestamp&gt;' : &lt;some_client_ip&gt; }
             {   '&lt;timestamp&gt;' : &lt;some_client_ip&gt; }
         }
     }
  }
  </code></pre>
  
  <p>Thanks!</p>