public ImmutableSortedSet<Name> snapshot() {
    ImmutableSortedSet.Builder<Name> builder =
        new ImmutableSortedSet.Builder<>(Name.displayOrdering());

    for (DirectoryEntry entry : this) {
      if (!isReserved(entry.name())) {
        builder.add(entry.name());
      }
    }

    return builder.build();
  }
@Test
  public void testSnapshot() {
    root.link(Name.simple("bar"), regularFile(10));
    root.link(Name.simple("abc"), regularFile(10));

    // does not include . or .. and is sorted by the name
    assertThat(root.snapshot())
        .containsExactly(Name.simple("abc"), Name.simple("bar"), Name.simple("foo"))
        .inOrder();
  }