Using itertools.combinations(iterable, r) to reduce the combinations and avoid running it twice some paths