private function mapFolders(SS_List $folders, $searchQuery=null) {
        $result=array();
        
        foreach($folders as $folder) {
            if(!empty($searchQuery) && $searchQuery!==false) {
                $searchEngine=Config::inst()->get('CodeBank', 'snippet_search_engine');
                if($searchEngine && class_exists($searchEngine) && in_array('ICodeBankSearchEngine', class_implements($searchEngine))) {
                    $searchEngine=new $searchEngine();
                }else {
                    //Class is missing or invalid so fallback to the default
                    $searchEngine=new DefaultCodeBankSearchEngine();
                }
                
                $snippets=$searchEngine->doSnippetSearch($searchQuery, false, $folder->ID);
            }else {
                $snippets=$folder->Snippets();
            }
            
            $snippets=$this->overviewList($snippets, 'Title', 'ID', 'LanguageID');
            
            if(!empty($searchQuery) && $searchQuery!==false && count($snippets)==0) {
                continue;
            }
            
            $result[]=array(
                            'id'=>$folder->ID,
                            'name'=>$folder->Name,
                            'languageID'=>$folder->LanguageID,
                            'folders'=>$this->mapFolders($folder->Folders(), $searchQuery),
                            'snippets'=>$snippets
                        );
        }
        
        return $result;
    }