Hierarchical tree with bubble up, cascade and folder selection capabilities

I'm looking for a way to show multi-selection hierarchical component (perhaps a tree) which allow selecting either leafs or folders, with both bubble-up and cascade functionality.

Lets say I use some folder hierarchy:

enter image description here

I'm thinking about 4-states checkbox (select without children -> select with children -> select only children -> unselect).

Any better solution?

I've seen this question but none of the answers fit :(

Edit: relating to each solution in the similar question:

  1. I cannot use a map as it is not location based hierarchy.
  2. Adding another leaf for selecting parent only is OK, but it duplicates entries and may increase the tree size.
  3. Miller columns doesn't solve this issue.
  4. Adding "select all" button on hover doesn't fix touch devices. Also it looks too complicated to me.