Move template function to custom module
hook_theme_registry_alter() allows a module to step in to override registered theme callback functions. In your case, you're looking to override the menu_tree__main_menu entry and replace its callback function: 

/**
 * Implements hook_theme_registry_alter().
 */
function MYMODULE_theme_registry_alter(&amp;$theme_registry) {
  if ($theme_registry['menu_tree__main_menu']) {
    // @TODO: override
    // $theme_registry['menu_tree__main_menu']['function']
    // $theme_registry['menu_tree__main_menu']['type']
    // $theme_registry['menu_tree__main_menu']['theme path']
    // for your new module theme function
  }
}


See the Return Value section of hook_theme() for more information on what a theme registry entry contains.