class DirUtil {

  public static Set<Path> filterSubpaths(
      Set<Path> _to_be_filtered, Set<Path> _filter, boolean _keep_subpaths) {
    final Set<Path> result = new HashSet<Path>();
    for (Path p1 : _to_be_filtered) {
      boolean is_sub = false;
      for (Path p2 : _filter) {
        if (p1.startsWith(p2)) {
          is_sub = true;
          if (_keep_subpaths) {
            result.add(p1);
            break;
          }
        }
      }
      if (!_keep_subpaths && !is_sub) {
        result.add(p1);
      }
    }
    return result;
  }

}