public static Object transform(Object root, DataIterator it, Transform<Object,Object> transform)
  {
    DataElement element;

    // don't transform in place because iterator behavior with replacements (which behave like a remove and an add) while iterating is undefined
    ArrayList<ToTransform> transformList = new ArrayList<>();
    while ((element = it.next()) != null)
    {
      transformList.add(new ToTransform(element));
    }

    for (ToTransform toTransform : transformList)
    {
      if (toTransform.isRoot())
      {
        root = transform.apply(toTransform._value);
      }
      else
      {
        toTransform.transform(transform);
      }
    }
    return root;
  }
@Test
  public void testTransformByPredicateAtPath() throws Exception
  {
    SimpleTestData data = IteratorTestData.createSimpleTestData();

    Builder.create(data.getDataElement(), IterationOrder.PRE_ORDER)
      .filterBy(Predicates.pathMatchesPattern("foo", Wildcard.ANY_ONE, "id"))
      .transform(plusTenTransform);

    assertEquals(data.getValue().getDataList("foo").getDataMap(0).getInteger("id").intValue(), 11);
    assertEquals(data.getValue().getDataList("foo").getDataMap(1).getInteger("id").intValue(), 12);
    assertEquals(data.getValue().getDataList("foo").getDataMap(2).getInteger("id").intValue(), 13);
  }