 import mx.core.FlexGlobals;
 import mx.core.IFlexDisplayObject;
 import mx.core.IMXMLObject;
-import mx.core.IRawChildrenContainer;
+import mx.core.IVisualElement;
+import mx.core.IVisualElementContainer;
 import mx.core.UIComponent;
 import mx.core.mx_internal;
 import mx.events.FlexEvent;

        var aNestLevel:int = (a is UIComponent) ? UIComponent(a).nestLevel : -1;
        var bNestLevel:int = (b is UIComponent) ? UIComponent(b).nestLevel : -1;

        var aIndex:int = aParent is IRawChildrenContainer ?
            IRawChildrenContainer(aParent).rawChildren.getChildIndex(a) :
            DisplayObjectContainer(aParent).getChildIndex(a);

        var bIndex:int = bParent is IRawChildrenContainer ?
            IRawChildrenContainer(bParent).rawChildren.getChildIndex(b) :
            DisplayObjectContainer(bParent).getChildIndex(b);

        if (aNestLevel > bNestLevel || (a.parent == b.parent && aIndex > bIndex))
            return 1;
        else if (aNestLevel < bNestLevel ||  (a.parent == b.parent && bIndex > aIndex))
            return -1;
        else if (a == b)
            return 0;

     */
    private function breadthOrderCompare(a:DisplayObject, b:DisplayObject):Number
    {
        var aParent:DisplayObjectContainer = a.parent;
        var bParent:DisplayObjectContainer = b.parent;
        
        if (!aParent || !bParent)
            return 0;
   
