another fix for using the Base_module_model::_tree method and using foriegn_keys. Also fixes links in cases where the URI path is different from the model name.