public static Set<PathSpec> getPresentPaths(MaskTree filter, Set<PathSpec> paths)
  {
    // this emulates the behavior of Rest.li server
    // if client does not specify any mask, the server receives null when retrieving the MaskTree
    // in this case, all fields are returned
    if (filter == null)
    {
      return paths;
    }

    final DataMap filterMap = filter.getDataMap();
    if (filter.getDataMap().isEmpty())
    {
      return Collections.emptySet();
    }

    final DataMap pathSpecMap = createPathSpecMap(paths);

    @SuppressWarnings("unchecked")
    final DataMap filteredPathSpecs = (DataMap) new PathSpecFilter().filter(pathSpecMap, filterMap);

    return validate(filteredPathSpecs, paths);
  }
@Test
  public void testPositiveMultiPaths()
  {
    final MaskTree filter = new MaskTree();
    filter.addOperation(new PathSpec("foo", "bar", "baz"), MaskOperation.POSITIVE_MASK_OP);

    final Collection<PathSpec> positivePaths = new HashSet<>(Arrays.asList(
      new PathSpec("foo"),
      new PathSpec("foo", "bar"),
      new PathSpec("foo", "bar", "baz"),
      new PathSpec("foo", "bar", "baz", "xyz"),
      new PathSpec("foo", "bar", "baz", "abc", "xyz")
    ));
    final Collection<PathSpec> negativePaths = new HashSet<>(Arrays.asList(
      new PathSpec("xyz"),
      new PathSpec("foo", "baz"),
      new PathSpec("foo", "xyz"),
      new PathSpec("foo", "bar", "xyz")
    ));

    // test false positive
    final Set<PathSpec> positiveResult = ProjectionUtil.getPresentPaths(filter, new HashSet<>(positivePaths));
    Assert.assertEquals(positiveResult, positivePaths);

    // test false negative
    final Set<PathSpec> negativeResult = ProjectionUtil.getPresentPaths(filter, new HashSet<>(negativePaths));
    Assert.assertTrue(negativeResult.isEmpty());

    final Set<PathSpec> combinedPaths = new HashSet<>(positivePaths);
    combinedPaths.addAll(negativePaths);

    // combine both to test internal ordering, overwrites, etc.
    final Set<PathSpec> combinedResult = ProjectionUtil.getPresentPaths(filter, combinedPaths);
    Assert.assertEquals(combinedResult, new HashSet<>(positivePaths));

    for (PathSpec p : negativePaths)
    {
      Assert.assertFalse(combinedResult.contains(p));
    }
  }