how can I traverse through all ul and li elements in a tree structure :

<ul>
<li><a href="#">Places</a>
<ul>
<li><a href="#">Mercury</a></li>
...