Hi Vince
So, with you mentioning # for the parent then you would seem to be trying to use the 'Alternative JSON format' as described in the docs.
The difference with this format is that the data is not expected to be nested. The javascript will do the nesting for you.
Your back-end code appears to be trying to create a nested set however.
You should get all your categories and then render them into the correct (flat) json fields.
But to start, I would first create a json string in the browser and make that look like you need the tree to look, then move that json block to the controller and serve it as a json response, then finally work out how you can convert your php model into that json block in the back end.
At the moment you are trying to do it all at once, but I think you need to gradually increase your understanding.