nodes: 0, module; 1, function_definition; 2, function_name:render; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:""" Render the menu into a sorted by order multi dict """; 12, assignment; 13, assignment; 14, pattern_list; 15, call; 16, block; 17, call; 18, identifier:menu_list; 19, list; 20, identifier:menu_index; 21, integer:0; 22, identifier:_; 23, identifier:menu; 24, attribute; 25, argument_list; 26, expression_statement; 27, expression_statement; 28, expression_statement; 29, if_statement; 30, for_statement; 31, expression_statement; 32, if_statement; 33, expression_statement; 34, attribute; 35, argument_list; 36, call; 37, identifier:items; 38, assignment; 39, assignment; 40, assignment; 41, comparison_operator:"visible" in menu["kwargs"]; 42, block; 43, identifier:s; 44, subscript; 45, block; 46, assignment; 47, subscript; 48, block; 49, else_clause; 50, augmented_assignment; 51, identifier:self; 52, identifier:_sort; 53, identifier:menu_list; 54, attribute; 55, argument_list; 56, identifier:subnav; 57, list; 58, subscript; 59, call; 60, subscript; 61, False; 62, string:"visible"; 63, subscript; 64, expression_statement; 65, identifier:menu; 66, string:"subnav"; 67, if_statement; 68, if_statement; 69, expression_statement; 70, expression_statement; 71, expression_statement; 72, expression_statement; 73, identifier:_kwargs; 74, subscript; 75, identifier:menu; 76, string:"title"; 77, expression_statement; 78, expression_statement; 79, block; 80, identifier:menu_index; 81, integer:1; 82, identifier:copy; 83, identifier:deepcopy; 84, attribute; 85, subscript; 86, string:"_id"; 87, identifier:str; 88, argument_list; 89, subscript; 90, string:"active"; 91, identifier:menu; 92, string:"kwargs"; 93, assignment; 94, subscript; 95, block; 96, comparison_operator:s["endpoint"] == request.endpoint; 97, block; 98, assignment; 99, augmented_assignment; 100, assignment; 101, call; 102, identifier:menu; 103, string:"kwargs"; 104, call; 105, call; 106, expression_statement; 107, identifier:self; 108, identifier:MENU; 109, identifier:menu; 110, string:"kwargs"; 111, identifier:menu_index; 112, identifier:menu; 113, string:"kwargs"; 114, subscript; 115, call; 116, identifier:s; 117, string:"title"; 118, expression_statement; 119, subscript; 120, attribute; 121, expression_statement; 122, expression_statement; 123, subscript; 124, call; 125, identifier:menu_index; 126, integer:1; 127, subscript; 128, call; 129, attribute; 130, argument_list; 131, attribute; 132, argument_list; 133, attribute; 134, argument_list; 135, augmented_assignment; 136, subscript; 137, string:"visible"; 138, attribute; 139, argument_list; 140, assignment; 141, identifier:s; 142, string:"endpoint"; 143, identifier:request; 144, identifier:endpoint; 145, assignment; 146, assignment; 147, identifier:s; 148, string:"visible"; 149, attribute; 150, argument_list; 151, identifier:s; 152, string:"_id"; 153, identifier:str; 154, argument_list; 155, identifier:subnav; 156, identifier:append; 157, identifier:s; 158, identifier:_kwargs; 159, identifier:update; 160, dictionary; 161, identifier:menu_list; 162, identifier:append; 163, identifier:_kwargs; 164, identifier:menu_list; 165, identifier:subnav; 166, identifier:menu; 167, string:"kwargs"; 168, identifier:self; 169, identifier:_test_visibility; 170, subscript; 171, subscript; 172, call; 173, subscript; 174, True; 175, subscript; 176, True; 177, identifier:self; 178, identifier:_test_visibility; 179, subscript; 180, identifier:menu_index; 181, pair; 182, pair; 183, pair; 184, subscript; 185, string:"visible"; 186, identifier:s; 187, string:"title"; 188, attribute; 189, argument_list; 190, identifier:s; 191, string:"active"; 192, subscript; 193, string:"active"; 194, identifier:s; 195, string:"visible"; 196, string:"subnav"; 197, call; 198, string:"order"; 199, subscript; 200, string:"title"; 201, call; 202, identifier:menu; 203, string:"kwargs"; 204, identifier:self; 205, identifier:_get_title; 206, subscript; 207, identifier:menu; 208, string:"kwargs"; 209, attribute; 210, argument_list; 211, identifier:menu; 212, string:"order"; 213, attribute; 214, argument_list; 215, identifier:s; 216, string:"title"; 217, identifier:self; 218, identifier:_sort; 219, identifier:subnav; 220, identifier:self; 221, identifier:_get_title; 222, subscript; 223, identifier:menu; 224, string:"title"
code: def render(self):
          """ Render the menu into a sorted by order multi dict """
          menu_list = []
          menu_index = 0
          for _, menu in copy.deepcopy(self.MENU).items():
              subnav = []
  
              menu["kwargs"]["_id"] = str(menu_index)
              menu["kwargs"]["active"] = False
              if "visible" in menu["kwargs"]:
                  menu["kwargs"]["visible"] = self._test_visibility(menu["kwargs"]["visible"])
  
              for s in menu["subnav"]:
                  if s["title"]:
                      s["title"] = self._get_title(s["title"])
  
                  if s["endpoint"] == request.endpoint:
                      s["active"] = True
                      menu["kwargs"]["active"] = True
                  s["visible"] = self._test_visibility(s["visible"])
                  menu_index += 1
                  s["_id"] = str(menu_index)
                  subnav.append(s)
  
              _kwargs = menu["kwargs"]
  
              if menu["title"]:
                  _kwargs.update({
                      "subnav": self._sort(subnav),
                      "order": menu["order"],
                      "title": self._get_title(menu["title"])
                  })
                  menu_list.append(_kwargs)
              else:
                  menu_list += subnav
              menu_index += 1
  
          return self._sort(menu_list)