code: public static Object keyForPrefixMatch(Object key, int depth) {
          if (depth < 1)
              return key;
          if (key instanceof String) {
              return (key + "\uFFFF");
          } else if (key instanceof List) {
              ArrayList<Map<String, Object>> nuKey = new ArrayList<Map<String, Object>>((List<Map<String, Object>>) key);
              if (depth == 1) {
                  nuKey.add(new HashMap<String, Object>());
              } else {
                  Object lastObject = nuKey.get(nuKey.size() - 1);
                  lastObject = keyForPrefixMatch(lastObject, depth - 1);
                  nuKey.set(nuKey.size() - 1, (Map<String, Object>) lastObject);
              }
              return nuKey;
          } else {
              return key;
          }
      }
docs: in CBLMisc.m
  id CBLKeyForPrefixMatch(id key, unsigned depth)