class DfsFilter implements ListFilter, Filter {

    @Override
    public List<UiObject> filter(List<UiObject> nodes) {
        ArrayList<UiObject> list = new ArrayList<>();
        for (UiObject node : nodes) {
            if (isIncluded(node)) {
                list.add(node);
            }
            filterChildren(node, list);
        }
        return list;
    }

}