 import com.esri.builder.components.serviceBrowser.nodes.FolderNode;
 import com.esri.builder.components.serviceBrowser.nodes.GPTaskNode;
 import com.esri.builder.components.serviceBrowser.nodes.LayerNode;
+import com.esri.builder.components.serviceBrowser.nodes.QueryableNode;
 import com.esri.builder.components.serviceBrowser.nodes.RouteLayerNode;
 import com.esri.builder.components.serviceBrowser.nodes.ServerNode;
 import com.esri.builder.components.serviceBrowser.nodes.ServiceDirectoryNode;

            if (tableNode)
            {
                tableNode.token = token;
                tableNodesToLoad.push(tableNode);
            }
        }

        if (layerNodesToLoad.length > 0)
        {
            allLayersProcessed = false;
            fetchLayerNodeInfo();
        }
        if (tableNodesToLoad.length > 0)
        {
            allTablesProcessed = false;
            fetchTableNodeInfo();
        }

        if (layerNodesToLoad.length == 0 && tableNodesToLoad.length == 0)
        {
            dispatchNodeFetchComplete();
        }
    }

    private function fetchLayerNodeInfo():void
    {
        totalLayerNodesToLoad = layerNodesToLoad.length;
        var urlVars:URLVariables;
        var layerInfoRequest:JSONTask;
        for each (var layerNode:LayerNode in layerNodesToLoad)
        {
            urlVars = new URLVariables();
            urlVars.f = "json";
            layerInfoRequest = new JSONTask(layerNode.internalURL);
            layerInfoRequest.requestTimeout = getValidRequestTimeout();
            layerInfoRequest.token = token;
            layerInfoRequest.execute(urlVars,
                                     new AsyncResponder(layerInfoRequest_resultHandler,
                                                        layerNodeInfoRequest_faultHandler,
                                                        layerNode));
        }
    }

    private function fetchTableNodeInfo():void
    {
        totalTableNodesToLoad = tableNodesToLoad.length;
        var urlVars:URLVariables;
        var tableInfoRequest:JSONTask;
        for each (var tableNode:TableNode in tableNodesToLoad)
        {
            urlVars = new URLVariables();
            urlVars.f = "json";
            tableInfoRequest = new JSONTask(tableNode.internalURL);
            tableInfoRequest.requestTimeout = getValidRequestTimeout();
            tableInfoRequest.token = token;
            tableInfoRequest.execute(urlVars,
                                     new AsyncResponder(tableInfoRequest_resultHandler,
                                                        tableNodeInfoRequest_faultHandler,
                                                        tableNode));
        }
    }

    private function layerNodeInfoRequest_faultHandler(fault:Fault, token:Object = null):void
    {
        layerProcessed();
    }

    private function tableNodeInfoRequest_faultHandler(fault:Fault, token:Object = null):void
    {
        tableProcessed();
    }

    private function layerProcessed():void
    {
        totalLayerNodesToLoad--;
        if (totalLayerNodesToLoad == 0)
        {
            addProcessedLayerNodesAndDispatchFetchComplete();
        }
    }

    private function tableProcessed():void
    {
        totalTableNodesToLoad--;
        if (totalTableNodesToLoad == 0)
        {
            addProcessedTableNodesAndDispatchFetchComplete();
        }
    }

    private function addProcessedLayerNodesAndDispatchFetchComplete():void
    {
        for each (var layerNode:LayerNode in layerNodesToLoad)
        {
            if (nodeFilter.isApplicable(layerNode))
            {
                nodes.push(layerNode);
            }
        }
        allLayersProcessed = true;
        if (allLayersProcessed && allTablesProcessed)
        {
            dispatchNodeFetchComplete();
        }
    }

    private function addProcessedTableNodesAndDispatchFetchComplete():void
    {
        for each (var tableNode:TableNode in tableNodesToLoad)
        {
            if (nodeFilter.isApplicable(tableNode))
            {
                nodes.push(tableNode);
            }
        }
        allTablesProcessed = true;
        if (allLayersProcessed && allTablesProcessed)
        {
            dispatchNodeFetchComplete();
        }

            }
        }

        nodesToLoad = [];
        for each (var layer:Object in metadata.layers)
        {
            const layerNode:LayerNode =
