move debug message to module where it belongs
remove useless length test, add documentation

testing the length before doing the pop(0) is not required as the previous code
will already catch that situation and terminate the loop accordingly