private static int getStubDepth(StubElement<?> stub) {
    int depth = 0;
    while (stub != null) {
      stub = stub.getParentStub();
      depth++;
    }
    return depth;
  }
private static int getStubDepth(StubElement<?> stub)