Simplify treemenu.php

This change does exact the same thing as the code block above, but is quite a bit shorter and easier to understand. :)