static int dp_maxval_helper(Node node, Map<Node, int[]>dp, boolean f) {
		if (node==null) 
			return 0;
		int v1,v2;
		int[] val=dp.get(node);
		if (val!=null) {
			v1=val[0];
			v2=val[1];
		} else {
			dp.put(node, val=new int[2]);
			v1=node.val;
			v2=0;
			for (Node c:node.child) {
				v1+=dp_maxval_helper(c, dp, true);
				v2+=dp_maxval_helper(c, dp, false);
			}
			val[0]=v1;
			val[1]=v2;
		}
		if (f)
			return v2;
		else 
			return v1>v2?v1:v2;
	}