contains method
Determines whether the specified DisplayObject is a child of this DisplayObjectContainer instance or the instance itself.
The search includes the entire display list including this DisplayObjectContainer instance. Grandchildren, great-grandchildren, and so on each return true.
Implementation
bool contains(DisplayObject child) {
DisplayObject? localChild = child;
while (localChild != null) {
if (localChild == this) return true;
localChild = localChild.parent;
}
return false;
}