public Iterator<String> reverseIterator() {

    return new Iterator<String>() {
      private String current = getFullPath();

      @Override
      public boolean hasNext() {
        return current != null;
      }

      @Override
      public String next() {
        if (!hasNext()) {
          throw new NoSuchElementException();
        }

        int parentQueueNameEndIndex = current.lastIndexOf(".");
        String old = current;
        if (parentQueueNameEndIndex > -1) {
          current = current.substring(0, parentQueueNameEndIndex).trim();
        } else {
          current = null;
        }

        return old;
      }
    };
  }
@Test
  public void testReversePathIterator() {
    List<String> queuePathCollection = ImmutableList.copyOf(TEST_QUEUE_PATH.reverseIterator());
    List<String> queuePathWithEmptyPartCollection = ImmutableList.copyOf(
        QUEUE_PATH_WITH_EMPTY_PART.reverseIterator());
    List<String> rootPathCollection = ImmutableList.copyOf(ROOT_PATH.reverseIterator());

    Assert.assertEquals(4, queuePathCollection.size());
    Assert.assertEquals(CapacitySchedulerConfiguration.ROOT,
        queuePathCollection.get(3));
    Assert.assertEquals(TEST_QUEUE, queuePathCollection.get(0));

    Assert.assertEquals(3, queuePathWithEmptyPartCollection.size());
    Assert.assertEquals(CapacitySchedulerConfiguration.ROOT,
        queuePathWithEmptyPartCollection.get(2));
    Assert.assertEquals("root..level_2", queuePathWithEmptyPartCollection.get(0));

    Assert.assertEquals(1, rootPathCollection.size());
    Assert.assertEquals(CapacitySchedulerConfiguration.ROOT,
        rootPathCollection.get(0));
  }