Unless you've already done that, it's definitely worth looking around the monastery searching for 'adjacency lists' and 'trees'. You might discover that there are many ways to tackle the problem - and that, where you thought having _one_ problem to solve, you're suddenly eager to solve _a bunch_ of problems that you ignored so far :)
That said, might be that DBIx::Tree is exactly what you're after - so far ;)