I have a tree structure like this one:
public class Project {
private String id;
private String description;
private List<Project> subProjects;
private List<Document> documents;
}
List<Project> projects = new ArrayList<Project>;
The projects can have subprojects or documents but not both at the same time. My problem is trying to filter this list by removing from it every project or subproject which has no documents. So we remove the project if the project have no documents and no subprojects, or if none of his subprojects have documents.
Can it be done recursively?