Partition lists when needed

Fixes #1022 
My point was 'did you intend to use this variable, since the current logic works like `pollLast()`'
It now removes the last path if it is non-empty, and `pathAdded` is unused.