public static Popup GetExistingPopup(Control parent, Type type)
{
foreach(Control ctrl in parent.Controls) {
if(ctrl.GetType().Equals(type))
return (ctrl as Popup);
else {
var foundControl = GetExistingPopup(ctrl, type);
if(foundControl != null)
return foundControl;
}
}
return null;
}