您好,我正在遍历用户定义的列表类型。是否可以递归地编写此代码?请帮我递归地重写它。
for (Tag tag : arpackages) {
List<Tag> arpackage = tag.getChildren();
for (Tag tag1 : arpackage) {
List<Tag> packages = tag1.getChildren();
for (Tag tag2 : packages) {
List<Tag> pack = tag2.getChildren();
for (Tag tag3 : pack) {
List<Tag> elements = tag3.getChildren();
for (Tag tag4 : elements) {
List<Tag> featureSelectionSet=tag4.getChildren(tagName);
if (featureSelectionSet.size() > 0) {
return featureSelectionSet;
}
}
}
}
}
}