Hi Scott,
As regards "tree -d" style functionality you might want to use
asset.namespace.describe :namespace /path/to/namespace :levels n
where n is an integer value. It produces a LOT of output so be wary of the computational cost of running this command with a high :levels value.
I suspect a better approach is to make use of the :text argument to asset.query. Something like this perhaps:
asset.query :action get-path :where ... :text "_todelete"
When I run that I get the assets that come back but it would be pretty straightforward to derive the relevant namespace(s) from that query.
Another thing to review is the documentation on
Asset Query Language. There might be something in there you can use to your advantage.
Cheers,
John