Mike,
It looks like you're doing a tree traversal. SQL in general is not very good at it. Tree traversals are inheirently (sp?) record oriented while SQL works in sets. In SQL For Smarties, Joe Celko has a solution that I've used in the past but it requires a pre-order traveral of the tree first. You might want to check that out.
-Mike