Christian Heilmann does a tree menu without using loops. It demonstrates the flexibility and power of Event delegation - catching events at a higher level in the document. It drastically cuts down on the number of events you need to add to a document. One event handler per menu, rather than one per link in the menu.
Christian Heilmann demonstrates delegating events, and compares it to the main alternative of assigning event handlers to each individual node. Its a technique that's important for writing applications that can scale.