/** * Recursively adds all items in the includedItems list to the * filteredChildren map in the same order as they are in the children map. * Starts from parentItemId and recurses down as long as child items that * should be included are found. * * @param parentItemId * The item id to start recurse from. Not added to a * filteredChildren list * @param includedItems * Set containing the item ids for the items that should be * included in the filteredChildren map */ private void addFilteredChildrenRecursively(Object parentItemId, HashSet<Object> includedItems) { LinkedList<Object> childList = children.get(parentItemId); if (childList == null) { return; } for (Object childItemId : childList) { if (includedItems.contains(childItemId)) { addFilteredChild(parentItemId, childItemId); addFilteredChildrenRecursively(childItemId, includedItems); } } }
addFilteredChild(itemParent, itemId);