pathslicer: implement a better list_content method
that prunes unnecessary directories when walking the root path.
Add a dedicated unit test.