[eluser]christian.schorn[/eluser]
One other thing I noted: For this to work there can be only one top-level object.
(This was something I just explicitly checked for, because I have a similar problem but with several top-level objects (CS-speak: I don't have a tree, but a forest

))
But this is the easiest thing to fix:
Code:
// snip
$new_page_array = array();
foreach ($page_array as $page) {
if (!isset($page->parent_thread)) {
$new_page_array[$page->permalink] = $page;
} else {
// snip
And just because it keeps bugging me, I'll try to find a way, where the order of the elements doesn't matter ...