"""Visit the switch and travel to the switchs linked to it.
:param switch_start: the switch to begin the visit on
:param switch_before: the switch that you come from. None if switch_start is the first one
:param detected: list of all switchs already visited. None if switch_start is the first one
:return: A list of all the links found and a list of all the switchs visited"""
:param switch_before: the switch that you come from.
None if switch_start is the first one
:param detected: list of all switchs already visited.
None if switch_start is the first one
:return: A list of all the links found and a list of
all the switchs visited
"""
detected.append(switch_start)
links_return=[]# list of dictionaries of the links to be detected
forportinswitch_start.ports.filter(related__isnull=False):# create links to every switchs below
ifport.related.switch!=switch_beforeandport.related.switch!=port.switchandport.related.switchnotindetected:# Not the switch that we come from, not the current switch
links_return=[]# list of dictionaries of the links to be detected