I would do something like this: use the Enumerable.OfType<>()
More info: https://msdn.microsoft.com/en-us/library/vstudio/bb360913(v=vs.100).aspx
foreach(var stackpanel in tmpList.OfType())
{
// search for the label. (the same trick)
var myLabel = stackpanel.Children.OfType