public static function restore_get_question_banks($restoreid, $contextlevel = null) {
        global $DB;

        $results = array();
        $qcats = $DB->get_recordset_sql("SELECT itemid, parentitemid AS contextid, info
                                         FROM {backup_ids_temp}
                                       WHERE backupid = ?
                                         AND itemname = 'question_category'", array($restoreid));
        foreach ($qcats as $qcat) {
            // If this qcat context haven't been acummulated yet, do that
            if (!isset($results[$qcat->contextid])) {
                $info = backup_controller_dbops::decode_backup_temp_info($qcat->info);
                // Filter by contextlevel if necessary
                if (is_null($contextlevel) || $contextlevel == $info->contextlevel) {
                    $results[$qcat->contextid] = $info->contextlevel;
                }
            }
        }
        $qcats->close();
        // Sort by value (contextlevel from CONTEXT_SYSTEM downto CONTEXT_MODULE)
        asort($results);
        return $results;
    }