public static Collection<Object> accumulateValues(DataIterator it, Collection<Object> accumulator)
  {
    for(DataElement element = it.next(); element !=null; element = it.next())
    {
      accumulator.add(element.getValue());
    }
    return accumulator;
  }
@Test
  public void testAccumulateByPath() throws Exception
  {
    SimpleTestData data = IteratorTestData.createSimpleTestData();

    List<Object> ids = new LinkedList<>();

    Builder.create(data.getDataElement(), IterationOrder.PRE_ORDER)
      .filterBy(Predicates.and(Predicates.pathMatchesPattern("foo", Wildcard.ANY_ONE, "id")))
      .accumulateValues(ids);

    assertEquals(3, ids.size());
    assertTrue(ids.contains(1));
    assertTrue(ids.contains(2));
    assertTrue(ids.contains(3));
  }