Jade,
I have a query that does that. You do use the context_id, but of course, you have to set the context_id to establish the hierarchy. Let me look up the query, but you can see it a t work at iunicycle.com, the categories have prefix dots indicating the depth.