Compare two menu tree objects I'm trying to add custom css class to a particular menu, same task mentioned here.

I moved a little further and found this article. So I put following code in template.php:

&lt;?php
function phptemplate_menu_tree($tree) {
  if ($tree == menu_tree()) {
    $output .= "&lt;ul id=\"foo\" class=\"bar\"&gt;";
    $output .= $tree;
    $output .= "&lt;/ul&gt;\n";
    return $output;
 } else {
  return '&lt;ul class="menu"&gt;'. $tree .'&lt;/ul&gt;';

 }
}
?&gt;


but constantly getting 502 error when trying to compare $tree and menu_tree().

Can anyone suggest what am I doing wrong?

UPDATE

I've fixed the initial issue in the question and posted the solution here. Hope it helps.
You cannot call menu_tree() from within theme_menu_tree() because menu_tree() contains a call to theme_menu_tree(). Your code contains an infinite loop.