public virtual NSView AncestorSharedWithView(NSView aView)
{
NSView self = this;
if (self == aView)
return self;
if (this.IsDescendantOf(aView))
return aView;
if (aView.IsDescendantOf(self))
return self;
/*
* If neither are descendants of each other and either does not have a
* superview then they cannot have a common ancestor
*/
if (_super_view == null)
return null;
if (aView.Superview == null)
return null;
/* Find the common ancestor of superviews */
return _super_view.AncestorSharedWithView((NSView)aView.Superview);
}