Can I use the function menu_tree() in Drupal 7 to customize a menu and add CSS classes?
The easiest way to add custom classes to menu items in Drupal 7 is the Menu Attributes module.

If you really want to do this programmatically, then you can override the theme_menu_link() function in your theme's template.php file. Be sure to read the drupal.org documentation on Overriding Themable Output.