@Nullable
  public String getLeadingPath(int n) {
    String path = mUri.getPath();
    if (n == 0 && path.indexOf(AlluxioURI.SEPARATOR) == 0) { // the special case
      return AlluxioURI.SEPARATOR;
    }
    int depth = getDepth();
    if (depth < n) {
      return null;
    } else if (depth == n) {
      return path;
    } else {
      String[] comp = path.split(SEPARATOR);
      return StringUtils.join(Arrays.asList(comp).subList(0, n + 1), SEPARATOR);
    }
  }
@Test
  public void getLeadingPath() {
    assertEquals("/",      new AlluxioURI("/a/b/c/").getLeadingPath(0));
    assertEquals("/a",     new AlluxioURI("/a/b/c/").getLeadingPath(1));
    assertEquals("/a/b",   new AlluxioURI("/a/b/c/").getLeadingPath(2));
    assertEquals("/a/b/c", new AlluxioURI("/a/b/c/").getLeadingPath(3));
    assertEquals(null,     new AlluxioURI("/a/b/c/").getLeadingPath(4));

    assertEquals("/",      new AlluxioURI("/").getLeadingPath(0));

    assertEquals("",       new AlluxioURI("").getLeadingPath(0));
    assertEquals(null,     new AlluxioURI("").getLeadingPath(1));
    assertEquals(".",       new AlluxioURI(".").getLeadingPath(0));
    assertEquals(null,     new AlluxioURI(".").getLeadingPath(1));
    assertEquals("a/b",    new AlluxioURI("a/b/c").getLeadingPath(1));
  }