code: private static ArrayList<File> getContentsInDirectoryTree(File directory, FileFilterRuleSet ruleSet, boolean returnFiles, boolean returnDirs) {
  		ArrayList<File> result = new ArrayList<File>();
  		if (directory != null && directory.exists() && directory.isDirectory()) {
  			File[] files = directory.listFiles();
  			if (files != null) {
  				for (int i = 0; i < files.length; i++) {
  
  					if (files[i].isDirectory()) {
  						if (returnDirs && ruleSet.fileMatchesRules(files[i])) {
  							result.add(files[i]);
  						}
  						result.addAll(getContentsInDirectoryTree(files[i], ruleSet, returnFiles, returnDirs));
  					}
  					else if (returnFiles && ruleSet.fileMatchesRules(files[i])) {
  						result.add(files[i]);
  					}
  				}
  			}
  		}
  		return result;
  	}
docs: Retrieves contents from a directory and its subdirectories matching a given rule set.
  
  @param directory directory
  @param ruleSet file name to match
  @param returnFiles return files
  @param returnDirs return directories
  @return a list containing the found contents