public void SetMax(ref int currMax) { interMediateMax.Add(maxSum); var interMax = interMediateMax.Max(); currMax = Math.Max(interMax, currMax); if (child != null) { child.SetMax(ref currMax); } }