<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _fetch_resource(self, session, api_type, obj_id, permission):
 """ Fetch a resource by type and id, also doing a permission check. :param session: SQLAlchemy session :param api_type: The type :param obj_id: ID for the resource :param permission: Permission to check """

        if api_type not in self.models.keys():
            raise ResourceTypeNotFoundError(api_type)
        obj = session.query(self.models[api_type]).get(obj_id)
        if obj is None:
            raise ResourceNotFoundError(self.models[api_type], obj_id)
        check_permission(obj, None, permission)
        return obj