aggiornamento: sono riuscito a ricreare una struttura ad albero degna di essere utilizzata 
Funzione di costruzione dell'albero
$id è il nodo di partenza
$albero è quello che viene restituito dalla funzionee
Codice PHP:
function ns_build_three($id) {
$id = (int)$id;
$right = array();
// retrieve the left and right value of the $root node
$result = mysql_query('SELECT sx, dx FROM personale WHERE id="'.$id.'";');
$row = mysql_fetch_array($result);
// now, retrieve all descendants of the $root node
$result = mysql_query('SELECT nome, sx, dx FROM personale WHERE sx BETWEEN '.$row['sx'].' AND '.$row['dx'].' ORDER BY sx ASC;');
// display each row
while ($row = mysql_fetch_array($result)) {
// only check stack if there is one
if (count($right)>0) {
// check if we should remove a node from the stack
while ($right[count($right)-1]<$row['dx']) {
array_pop($right);
}
}
// display indented node title
$albero[] = array(count($right), $row['nome']);
// add this node to the stack
$right[] = $row['dx'];
}
return $albero;
}
questa è il codice che richiama la precedente funzione:
nel mio caso parto dall'id 1 (la mia radice)
Codice PHP:
$rows = ns_build_three(1);
$livello = -1;
foreach ($rows as $row) {
if ($livello < $row[0]) {
echo "<ul>\n";
} elseif ($livello > $row[0]) {
echo "[/list]\n";
} elseif ($livello == $row[0]) {
echo "\n";
}
echo "[*]".$row[1];
$livello = $row[0]; // imposto il vecchio livello per sapere come devo salire o scendere nell'albero
}
echo "";
while ($livello > 0) { // scendo i livelli della lista fino a chiuderla
echo "[/list]\n";
$livello = $livello - 1;
}
echo "[/list]";
ed ecco infine il codice risultante: (l'ho formattato a mano per renderlo più chiaro, comunque apre e chiude tutti i tag correttamente
)
codice:
<ul>
[*]Massimiliano
<ul>
[*]Francesco
<ul>
[*]Mario
[*]Luigi
[*]Fabio
<ul>
[*]Piero
<ul>
[*]Marco
[/list]
[*]Gianni
[/list]
[*]Gianni
[/list]
[/list]
[/list]