here the indention is off too. i think from if ($childNode instanceof on you should move things 4 spaces left.