nodes: 0, module; 1, function_definition; 2, function_name:generate_querystring; 3, parameters; 4, block; 5, identifier:params; 6, expression_statement; 7, if_statement; 8, expression_statement; 9, for_statement; 10, if_statement; 11, comment:"""
      Generate a querystring suitable for use in the v2 api.
  
      The Requests library doesn't know how to generate querystrings that encode dictionaries using square brackets:
      https://api.mollie.com/v2/methods?amount[value]=100.00&amount[currency]=USD
  
      Note: we use `sorted()` to work around a difference in iteration behaviour between Python 2 and 3.
      This makes the output predictable, and ordering of querystring parameters shouldn't matter.
      """; 12, not_operator; 13, block; 14, assignment; 15, pattern_list; 16, call; 17, block; 18, identifier:parts; 19, block; 20, identifier:params; 21, return_statement; 22, identifier:parts; 23, list; 24, identifier:param; 25, identifier:value; 26, identifier:sorted; 27, argument_list; 28, if_statement; 29, return_statement; 30, None; 31, call; 32, not_operator; 33, block; 34, else_clause; 35, call; 36, attribute; 37, argument_list; 38, call; 39, expression_statement; 40, comment:# encode dictionary with square brackets; 41, block; 42, attribute; 43, argument_list; 44, identifier:params; 45, identifier:items; 46, identifier:isinstance; 47, argument_list; 48, call; 49, for_statement; 50, string; 51, identifier:join; 52, identifier:parts; 53, identifier:value; 54, identifier:dict; 55, attribute; 56, argument_list; 57, pattern_list; 58, call; 59, block; 60, string_content:&; 61, identifier:parts; 62, identifier:append; 63, call; 64, identifier:key; 65, identifier:sub_value; 66, identifier:sorted; 67, argument_list; 68, expression_statement; 69, expression_statement; 70, identifier:urlencode; 71, argument_list; 72, call; 73, assignment; 74, call; 75, dictionary; 76, attribute; 77, argument_list; 78, identifier:composed; 79, call; 80, attribute; 81, argument_list; 82, pair; 83, identifier:value; 84, identifier:items; 85, attribute; 86, argument_list; 87, identifier:parts; 88, identifier:append; 89, call; 90, identifier:param; 91, identifier:value; 92, string; 93, identifier:format; 94, keyword_argument; 95, keyword_argument; 96, identifier:urlencode; 97, argument_list; 98, string_content:{param}[{key}]; 99, identifier:param; 100, identifier:param; 101, identifier:key; 102, identifier:key; 103, dictionary; 104, pair; 105, identifier:composed; 106, identifier:sub_value
code: def generate_querystring(params):
      """
      Generate a querystring suitable for use in the v2 api.
  
      The Requests library doesn't know how to generate querystrings that encode dictionaries using square brackets:
      https://api.mollie.com/v2/methods?amount[value]=100.00&amount[currency]=USD
  
      Note: we use `sorted()` to work around a difference in iteration behaviour between Python 2 and 3.
      This makes the output predictable, and ordering of querystring parameters shouldn't matter.
      """
      if not params:
          return None
      parts = []
      for param, value in sorted(params.items()):
          if not isinstance(value, dict):
              parts.append(urlencode({param: value}))
          else:
              # encode dictionary with square brackets
              for key, sub_value in sorted(value.items()):
                  composed = '{param}[{key}]'.format(param=param, key=key)
                  parts.append(urlencode({composed: sub_value}))
      if parts:
          return '&'.join(parts)