public static long GetLength(Box box) { long length = 0; foreach (var item in box.Seeds) { length += item.Length; } foreach (var item in box.Boxes) { length += GetLength(item); } return length; }