sidebar tree #1813 implements the "in folder part" through the side bar, i.e. when you close a folder (via popup menu or middle mouse click) then all files below that folder will be closed. The other use case could probably also be implemented there. Do you think it makes this PR obsolete?
I never use the notebook popup menu, mainly because I always have many files open so I always have to scroll.