Moved code from tree.js to display.php