class QuarkCube {

  public static Set<Set<Dimension>> getDimensionSets(Set<Dimension> dimensions) {
    Set<Set<Dimension>> result = Sets.newHashSet();
    result.add(new HashSet<>());
    for (Dimension d : dimensions) {
      // traverse only the top level dimension i.e., with no parents
      if (d.parentDimension == null) {
        result = cartesian(ImmutableList.of(result,
            getHierarichalSet(d, new AtomicBoolean(false))));
      }
    }
    return result;
  }

}

class QuarkCubeTest {

  public Fixture fixture;

  @Test
  public void computeDimensionSet() {

    Set<Set<QuarkCube.Dimension>> dimSet = QuarkCube.getDimensionSets(
        fixture.getAllDim());
    assertEquals(dimSet.size(), 8);
  }

}