title: check if element in values also in key in dict
body: <p>I have the input dict as :-</p>
  
  <pre><code>classDict = {'G1': ['V1', 'G3', 'V2'], 
              'G2': ['G4', 'V3'], 
              'G3': ['V2'], 
              'G4': ['V3'], 
              'G5': ['G6'], 
              'G6': ['G2', 'G4', 'V3'], 
              'G7': ['reset']
              }
  </code></pre>
  
  <p>Which I need to convert into :-</p>
  
  <pre><code>finalStructure = {'G1': {'value':['V1','V2'],
                            'group':'G3'},         
                     'G2': {'value':'V3',
                            'group':'G4'},
                     'G3': {'value':'V2'}, 
                     'G4': {'value':'V3'},  
                     'G5': {'group':'G6'}, 
                     'G6': {'group':['G2', 'G4'],
                            'value':'V3'}, 
                     'G7': {'value':'reset'}
                     }
  </code></pre>
  
  <p>the problem here is that the values in the dicts are also keys at some places. I need to find them than add them to the new dictionary as a value. The real purpose behind this problem is to create flat class structure where the V1, V2 etc are the functions and G1 , G2 etc are classes. If a class G1 has another class G3 in its group then it should instantiate that class. 
  Please don't use RE to differentiate 'G' and 'V' character as they are only pseudo names and the real names are completely different.  </p>