code: public int getNextDescendant(int subtreeRootHandle, int nodeHandle) {
                  subtreeRootHandle &= NODEHANDLE_MASK;
                  nodeHandle &= NODEHANDLE_MASK;
                  // Document root [Document Node? -- jjk] - no next-sib
                  if (nodeHandle == 0)
                          return NULL;
                  while (!m_isError) {
                          // Document done and node out of bounds
                          if (done && (nodeHandle > nodes.slotsUsed()))
                                  break;
                          if (nodeHandle > subtreeRootHandle) {
                                  nodes.readSlot(nodeHandle+1, gotslot);
                                  if (gotslot[2] != 0) {
                                          short type = (short) (gotslot[0] & 0xFFFF);
                                          if (type == ATTRIBUTE_NODE) {
                                                  nodeHandle +=2;
                                          } else {
                                                  int nextParentPos = gotslot[1];
                                                  if (nextParentPos >= subtreeRootHandle)
                                                          return (m_docHandle | (nodeHandle+1));
                                                  else
                                                          break;
                                          }
                                  } else if (!done) {
                                          // Add wait logic here
                                  } else
                                          break;
                          } else {
                                  nodeHandle++;
                          }
                  }
                  // Probably should throw error here like original instead of returning
                  return NULL;
          }
docs: Given a node handle, advance to its next descendant.
  If not yet resolved, waits for more nodes to be added to the document and
  tries again.
  
  @param subtreeRootHandle
  @param nodeHandle int Handle of the node.
  @return handle of next descendant,
  or DTM.NULL to indicate none exists.