This is a silly question, but you can use this code to check if something is a particular type...
if (child is IContainer) { //....
Is ther
C# 9 (released with .NET 5) includes the logical patterns and, or and not, which allows us to write this more elegantly:
and
or
not
if (child is not IContainer) { ... }
Likewise, this pattern can be used to check for null:
if (child is not null) { ... }