public OptionGroup findOptionGroup(String subKey) { int pos = subKey.indexOf('.'); if (pos == -1) { // check if the key specifies a group or a key: if the group is not known, assume its an // option key if (subGroups.containsKey(subKey)) { return subGroups.get(subKey); } else { return this; } } OptionGroup group = subGroups.get(subKey.substring(0, pos)); if (group == null) { // no subgroup by that key, return this group return this; } return group.findOptionGroup(subKey.substring(pos + 1)); }