public IEnumerable <ButtonSetup>?GetAllButtons() { if (Buttons != null) { foreach (var button in Buttons.GetAllButtons()) { yield return(button); } } if (Panes != null) { foreach (var button in Panes.SelectMany(pane => pane.Buttons.GetAllButtons())) { yield return(button); } } }