<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _find_relation_factory(module):
 """ Attempt to find a RelationFactory subclass in the module. Note: RelationFactory and RelationBase are ignored so they may be imported to be used as base classes without fear. """

    if not module:
        return None

    # All the RelationFactory subclasses
    candidates = [o for o in (getattr(module, attr) for attr in dir(module))
                  if (o is not RelationFactory and
                      o is not RelationBase and
                      isclass(o) and
                      issubclass(o, RelationFactory))]

    # Filter out any factories that are superclasses of another factory
    # (none of the other factories subclass it). This usually makes
    # the explict check for RelationBase and RelationFactory unnecessary.
    candidates = [c1 for c1 in candidates
                  if not any(issubclass(c2, c1) for c2 in candidates
                             if c1 is not c2)]

    if not candidates:
        hookenv.log('No RelationFactory found in {}'.format(module.__name__),
                    hookenv.WARNING)
        return None

    if len(candidates) > 1:
        raise RuntimeError('Too many RelationFactory found in {}'
                           ''.format(module.__name__))

    return candidates[0]