public static function handleTreeRequest($rootNode = null)
 {
     set_time_limit(1800);
     $rootPath = $rootNode ? $rootNode->getFullPath(null, false) : null;
     $collectionConditions = array();
     $fileConditions = array();
     // process excludes
     if (!empty($_REQUEST['exclude']) && method_exists('Emergence_FS', 'getNodesFromPattern')) {
         $excludes = is_array($_REQUEST['exclude']) ? $_REQUEST['exclude'] : array($_REQUEST['exclude']);
         $excludedCollections = array();
         $excludedFiles = array();
         foreach (Emergence_FS::getNodesFromPattern($excludes) as $node) {
             if ($node->Class == 'SiteCollection') {
                 $excludedCollections[] = $node->ID;
             } else {
                 $excludedFiles[] = $node->ID;
             }
         }
         if (count($excludedCollections)) {
             $collectionConditions['excludeTrees'] = $excludedCollections;
         }
         if (count($excludedFiles)) {
             $fileConditions[] = 'ID NOT IN (' . implode(',', $excludedFiles) . ')';
         }
     }
     // get files
     $files = Emergence_FS::getTreeFiles($rootPath, false, $fileConditions, $collectionConditions);
     header('HTTP/1.1 300 Multiple Choices');
     header('Content-Type: application/vnd.emergence.tree+json');
     print json_encode(array('total' => count($files), 'files' => $files));
     exit;
 }