Returns maximum sum from subset of nodes of binary tree under given constraints
public static int maxSum ( Node root ) { Pair res = maxSumHelper ( root ) ; return Math . Max ( res . first , res . second ) ; }