Need to create Hierarchy from given JSON

Input JSON

 node =[{'category_id': '1',
              'name': 'Root Category',
              'category_ids': ['2'],
              'item_ids': []},
             {'category_id': '2',
              'name': 'sub1 Category',
              'category_ids': ['18','19','20'],
              'item_ids': []},
                 {'category_id': '18',
              'name': 'sub2 Category',
              'category_ids': ['25'],
              'item_ids': []
            }
               ,   {'category_id': '19',
              'name': 'sub3 Category',
              'category_ids': [],
              'item_ids': ['222',
               '223',
               '224',
               '225']
            }  
            ..... goes on till no subcategory available 
                  ]

Depth of Category-Subcategory not known upfront

Final output should look like this

categories -> subcategories -> children

     {
            'category_id':'1',
            'subcategories':[
            {
            category_id:"2",
            'subcategories':[
            {
            category_id:19,
            "children" :['222',
               '223',
               '224',
               '225']
            },
            {
            "category_id":"18"
            .... so on 
        }
            ]
            },
            
            ]
      }

Looking for a way to iterate over this in an efficient way to produce above output using python