             var isEmpty:Boolean = true;
             var errMsg:String = "";
             
-            // TODO (jszeto) Figure out how to do the proper ordering 
-            for (key in invalidElements)
+            for (var i:int = 0; i < invalidElements.length; i++)
             {
                 isEmpty = false;
                 if (errMsg != "")

    
    /**
     *  @private
     *  If one of our descendants has just passed validation, then
     *  remove it from the invalidElements dictionary
     */

            // Either set this to the concatenated string or empty string
            errorString = errMsg;
        }
        else if (enabled && invalidElements.length > 0)
        {
            result = "error";
        }
            
        return result;
    }
    
    /**
     *  @private
     *  Used to sort the element positions calculated using getElementNestedPosition. 
     *  
     *  @param item1 first element to compare
     *  @param item2 second element to compare
     *  @return -1 if item1 is less than item2, 0 if they are equal, 
     *  1 if item1 is greater than item2 
     */
    private function compareNestedPosition(item1:Object, item2:Object):int
    {
        var item1Pos:Vector.<int> = item1.position;
        var item2Pos:Vector.<int> = item2.position;
        
        var item1Depth:int = item1Pos.length;
        var item2Depth:int = item2Pos.length;
        
        var minDepth:int = Math.min(item1Depth, item2Depth);
        
        var currentDepth:int = 0;
        
        // Iterate through the elements of the position Vectors
        // Each element in the Vectors represents a level in the display list tree
        // We compare the child index of each element at each depth
        // If they are equal, then we move down to the next depth
        while (currentDepth < minDepth)
        {
            var item1Value:int = item1Pos[currentDepth];
            var item2Value:int = item2Pos[currentDepth];
            
            if (item1Value < item2Value)
                return -1;
            else if (item1Value > item2Value)
                return 1;
            else
            {
                currentDepth++;
            }
        } 
        
        // If all of the previous levels shared the same child index, then
        // compare the depth of the elements. A deeper element is always greater
        // if the elements share the same ancestors. 
        if (item1Depth < item2Depth)
            return -1;
        else if (item1Depth > item2Depth)
            return 1;
        else
            return 0;
    }
    
    /**
     *  @private
     *  Helper function to find a target in the invalidElementsArray
     */
    private function findInvalidElementIndex(element:UIComponent):int
    {
        for (var i:int = 0; i < invalidElements.length; i++)
        {
            if (element == invalidElements[i].element)
                return i;
        }
        
        return -1;
    }
    
    /**
     *  @private
     *  
     *  Calculates the position of the target relative to the subTreeRoot. Used to compare the position
     *  of two tree nodes. The return value is a Vector of ints. Each int represents the childIndex of the 
     *  target's ancestor at a particular depth. The highest depths are at the beginning of the Vector
     * 
     *  @param target Return the position of this displayObject 
     *  @param subTreeRoot The displayObject to use as the root of the subTree
     *  
     *  @return a Vector of ints representing the position of the target in the display list tree
     * 
     */
    private function getElementNestedPosition(target:DisplayObject, subTreeRoot:DisplayObjectContainer = undefined):Vector.<int>
    {
        var p:DisplayObjectContainer = target.parent;
        var current:DisplayObject = target;
        var pos:Vector.<int> = new Vector.<int>();
        
        if (p == null || current == subTreeRoot)
        {
            pos.push(0);
        }
        else
        {
            while (p != null && current != subTreeRoot)
            {
                pos.splice(0, 0, p.getChildIndex(current));
                current = p;
                p = p.parent;
            }
        
        }
        return pos;
    }
    
    
}
}
