IdPath { public IdPath getParent() { if (myParts.length == 1) return null; int[] newPath = new int[myParts.length - 1]; System.arraycopy(myParts, 0, newPath, 0, newPath.length); return new IdPath(newPath); } IdPath(int... parts);  IdPath(Stream s); void write(Stream s); int getId(); IdPath getParent(); IdPath appendedWith(int id); boolean isChildOrParentOf(IdPath p); boolean contains(int id); boolean startsWith(IdPath p); boolean rootEquals(int id); IdPath withoutRoot(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testParent() { assertEquals(new IdPath(1, 2), new IdPath(1, 2, 3).getParent()); assertEquals(new IdPath(1), new IdPath(1, 2).getParent()); assertNull(new IdPath(1).getParent()); }