<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_factory_by_class(self, klass):
 """ Returns a custom factory for class. By default it will return the class itself. :param klass: Class type :type klass: type :return: Class factory :rtype: callable """

        for check, factory in self._factories.items():
            if klass is check:
                return factory(self, klass)
        for check, factory in self._factories.items():
            if issubclass(klass, check):
                return factory(self, klass)
        return klass