internal static void ForEachChildAndNodeBreadth <TNodeType>(DependencyObject node, Func <TNodeType, bool> callback) where TNodeType : class { foreach (DependencyObject dependencyObject in VisualTreeExtensions.GetVisualDescendantsAndSelf(node)) { TNodeType nodeType = dependencyObject as TNodeType; if ((object)nodeType != null && !callback(nodeType)) { break; } } }