winmenu: optimized by getting the tree once
Incorporates joepvd/winmenu's latest.