code: def _render_section(self, output, params, indent=0):
          
  
          for key, val in sorted(params.items()):
              if key.upper() != key:
                  raise InputValidationError("keyword '%s' not upper case" % key)
              if key.startswith('@') or key.startswith('$'):
                  raise InputValidationError("CP2K preprocessor not supported")
              if isinstance(val, dict):
                  output.append('%s&%s %s' % (' ' * indent, key, val.pop('_', '')))
                  self._render_section(output, val, indent + 3)
                  output.append('%s&END %s' % (' ' * indent, key))
              elif isinstance(val, list):
                  for listitem in val:
                      self._render_section(output, {key: listitem}, indent)
              elif isinstance(val, bool):
                  val_str = '.true.' if val else '.false.'
                  output.append('%s%s  %s' % (' ' * indent, key, val_str))
              else:
                  output.append('%s%s  %s' % (' ' * indent, key, val))
docs: It takes a dictionary and recurses through.
  
          For key-value pair it checks whether the value is a dictionary
          and prepends the key with &
          It passes the valued to the same function, increasing the indentation
          If the value is a list, I assume that this is something the user
          wants to store repetitively
          eg:
              dict['KEY'] = ['val1', 'val2']
              ===>
              KEY val1
              KEY val2
  
              or
  
              dict['KIND'] = [{'_': 'Ba', 'ELEMENT':'Ba'},
                              {'_': 'Ti', 'ELEMENT':'Ti'},
                              {'_': 'O', 'ELEMENT':'O'}]
              ====>
                    &KIND Ba
                       ELEMENT  Ba
                    &END KIND
                    &KIND Ti
                       ELEMENT  Ti
                    &END KIND
                    &KIND O
                       ELEMENT  O
                    &END KIND