Ho qusta funzione in php5..il problema è che deve girare su php4

function w() {
if($this->sons == NULL)
return 1;

$sum = 0;

for($i=0; $i<$this->sons->countSons(); $i++) {
$sum += $this->sons->at($i)->w();
}

return $sum;
}

quando lancio la pagina mi stampa il seguente errore
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /web/htdocs/www.coopsse.it/home/magdapesce/tree/Node.php on line 31

C'è un sistema per adattarla a php4?
GRAZIE!