public static void Foreach(this ITree tree, TreeIter action) { if (tree is ATreeCntr cntr) { for (int i = 0; i < cntr.Count; i++) { Foreach(cntr.trees[i], action); } } else { action?.Invoke(ref tree); } }