Source:
<code>protected String[] getCategoryMembers(String name, int maxdepth, List<String> visitedcategories, int... ns) throws IOException { name = name.replaceFirst("^(Category|" + namespaceIdentifier(CATEGORY_NAMESPACE) + "):", ""); StringBuilder url = new StringBuilder(query); url.append("list=categorymembers&cmprop=title&cmlimit=max&cmtitle="); url.append(encode("Category:" + name, true)); boolean nocat = ns.length != 0; if (maxdepth > 0 && nocat) { for (int i = 0; nocat && i < ns.length; i++) nocat = (ns[i] != CATEGORY_NAMESPACE); if (nocat) { int[] temp = Arrays.copyOf(ns, ns.length + 1); temp[ns.length] = CATEGORY_NAMESPACE; constructNamespaceString(url, "cm", temp); } else constructNamespaceString(url, "cm", ns); } else constructNamespaceString(url, "cm", ns); List<String> members = new ArrayList<>(); String next = ""; do { if (!next.isEmpty()) next = "&cmcontinue=" + encode(next, false); String line = fetch(url.toString() + next, "getCategoryMembers"); next = parseAttribute(line, "cmcontinue", 0); for (int x = line.indexOf("<cm "); x > 0; x = line.indexOf("<cm ", ++x)) { String member = parseAttribute(line, "title", x); boolean iscat = namespace(member) == CATEGORY_NAMESPACE; if (maxdepth > 0 && iscat && !visitedcategories.contains(member)) { visitedcategories.add(member); <START> String[] categoryMembers = getCategoryMembers(member, --maxdepth, visitedcategories, ns); <END> members.addAll(Arrays.asList(categoryMembers)); } if (!(maxdepth > 0) || !nocat || !iscat) members.add(member); } } while (next != null); int size = members.size(); log(Level.INFO, "getCategoryMembers", "Successfully retrieved contents of Category:" + name + " (" + size + " items)"); return members.toArray(new String[size]); }</code><technical_language>this maxdepth - 1</technical_language>

Target:
protected String[] getCategoryMembers(String name, int maxdepth, List<String> visitedcategories, int... ns) throws IOException { name = name.replaceFirst("^(Category|" + namespaceIdentifier(CATEGORY_NAMESPACE) + "):", ""); StringBuilder url = new StringBuilder(query); url.append("list=categorymembers&cmprop=title&cmlimit=max&cmtitle="); url.append(encode("Category:" + name, true)); boolean nocat = ns.length != 0; if (maxdepth > 0 && nocat) { for (int i = 0; nocat && i < ns.length; i++) nocat = (ns[i] != CATEGORY_NAMESPACE); if (nocat) { int[] temp = Arrays.copyOf(ns, ns.length + 1); temp[ns.length] = CATEGORY_NAMESPACE; constructNamespaceString(url, "cm", temp); } else constructNamespaceString(url, "cm", ns); } else constructNamespaceString(url, "cm", ns); List<String> members = new ArrayList<>(); String next = ""; do { if (!next.isEmpty()) next = "&cmcontinue=" + encode(next, false); String line = fetch(url.toString() + next, "getCategoryMembers"); next = parseAttribute(line, "cmcontinue", 0); for (int x = line.indexOf("<cm "); x > 0; x = line.indexOf("<cm ", ++x)) { String member = parseAttribute(line, "title", x); boolean iscat = namespace(member) == CATEGORY_NAMESPACE; if (maxdepth > 0 && iscat && !visitedcategories.contains(member)) { visitedcategories.add(member); String[] categoryMembers = getCategoryMembers(member, maxdepth - 1, visitedcategories, ns); members.addAll(Arrays.asList(categoryMembers)); } if (!(maxdepth > 0) || !nocat || !iscat) members.add(member); } } while (next != null); int size = members.size(); log(Level.INFO, "getCategoryMembers", "Successfully retrieved contents of Category:" + name + " (" + size + " items)"); return members.toArray(new String[size]); }