debnetworki.py without reduce (Python3 compatible)