shortest_path =Noneshortest_paths = []forpathinshortest_simple_paths(g, device_entity, gateway_entity): path_len = len(path)ifnotshortest_pathorpath_len <= shortest_path:# Interested in all paths the same length as the shortest.shortest_path = path_len shortest_paths.append(path)else:# ...