Doing a CMS for myself right now I must say: Don't do it. You get very far very soon (multi-user, stages, multi-site, languages, templates, media-handling, ...) but in the end it gets hard.
Of course it's a good study and stuff but there are a lot good free CMSs based on PHP which suit standard needs quite well. As for me I'm out of luck - I haven't found one to fit ;(
But I understand that you do it for a client, so maybe you don't have a choice so I'll try to be productive 🙂
I don't see your problem in more than one level. To get from one leaf section down to the root (which is easier than root to leaf and results in the same) I use something like this:
The leaf has a $parent so I can do a loop:
do {
// database abstractionlayer here,
// returns the parent group in $mg
$dblib->s_mediagroup($parent, &$mg);
$id = $mg['id'];
$parent = $mg['parent'];
$p = $id . "/" . $p;
} while ($parent != 0);
This loop stops when it finds a group (in $mg) whose $parent equals zero (so it's a root entry).
in $p I then have a directory path which in my case is just what I need since I store the media in directories matching the databases treelike structure.
In your case I'd change it to an array though.
Looks a little weird, esp. because of the abstractionlayer but it's pretty straight forward and should work for all treelike structures.
Greets,
Dominique