code: def render_categories(results):
      return json.dumps(
          {
              cat.name: {
                  subcat.name: [res.path for res in catresults]
                  for subcat, catresults in subcats.items()
                  if catresults
              }
              for cat, subcats in results.items()
              if subcats
              and sum(
                  len(catresults) for catresults in subcats.values()
              )
          }
      )
  
label_desc: Use image node_id 1 for calling a global function with example usage: render_categories(results) and returns: json