def get_related_models_recursive(model):
 seen = set()
 queue = _get_related_models(model)
 for rel_mod in queue:
  (rel_app_label, rel_model_name) = (rel_mod._meta.app_label, rel_mod._meta.model_name)
  if ((rel_app_label, rel_model_name) in seen):
   continue
  seen.add((rel_app_label, rel_model_name))
  queue.extend(_get_related_models(rel_mod))
 return (seen - {(model._meta.app_label, model._meta.model_name)})

def get_related_models_recursive ( model ) : seen = set ( ) queue = _get_related_models ( model ) for rel_mod in queue : ( rel_app_label , rel_model_name ) = ( rel_mod . _meta . app_label , rel_mod . _meta . model_name ) if ( ( rel_app_label , rel_model_name ) in seen ) : continue seen . add ( ( rel_app_label , rel_model_name ) ) queue . extend ( _get_related_models ( rel_mod ) ) return ( seen - { ( model . _meta . app_label , model . _meta . model_name ) } )
return all models that have a direct or indirect relationship to the given model .