private ReadPreference createReadPreference(final Map<String, List<String>> optionsMap) {
        Boolean slaveOk = null;
        String readPreferenceType = null;
        DBObject firstTagSet = null;
        List<DBObject> remainingTagSets = new ArrayList<DBObject>();

        for (String key : readPreferenceKeys) {
            String value = getLastValue(optionsMap, key);
            if (value == null) {
                continue;
            }

            if (key.equals("slaveok")) {
                slaveOk = _parseBoolean(value);
            } else if (key.equals("readpreference")) {
                readPreferenceType = value;
            } else if (key.equals("readpreferencetags")) {
                for (String cur : optionsMap.get(key)) {
                    DBObject tagSet = getTagSet(cur.trim());
                    if (firstTagSet == null) {
                        firstTagSet = tagSet;
                    } else {
                        remainingTagSets.add(tagSet);
                    }
                }
            }
        }
        return buildReadPreference(readPreferenceType, firstTagSet, remainingTagSets, slaveOk);
    }