Find most valuable subset of a node weighed tree
I forget the name but it's a classic minimum-cut problem. You can always consider min-cut approach when you want to choose an optimal subset. 

(Edit: It's called "project selection problem".)

Think about cutting nodes into two partitions $S$, $T$ and $S$ is what we choose. Ideally we want $S$ to contain all the positive nodes and avoid any negative node. However, it's not always possible. If there exists an edge $(u,v)$, $u\in S\to v\in S$. In the min-cut model, it means we can't cut this edge, so we set $capacity(u,v)=\inf$. Next consider what we should pay if we can't assign them ideally.

Create a source $s$ and a target $t$. For each node $u$, if $w_u$ is positive, add an edge $(s,u)$ and set $capacity(s,u)=w_u$. It means we lose $w_u$ if $u\notin S$. If $w_u$ is negative, add $(u,t)$ and set $capacity(u,t)=-w_u$. It means we lose $-w_u$ if $u \in S$. 

The answer is $\sum_{w_u&gt;0} w_u-min cut(s,t)$, and $M$ is the source partition.