int pos = (int) (rnd.nextDouble() * (root.getSubteeSize() - forbiddenTree.getSubteeSize() )); MarkableBaseNode found = doGetRandomNode( pos, root, isUnmarked, forbiddenTree ); if( found == null && isUnmarked ) found=doGetRandomNode(SCAN_UNMARKED,root,isUnmarked, forbiddenTree );
int pos = (int) (rnd.nextDouble() * (root.getSubteeSize() - (forbiddenTree == null ? 0 : forbiddenTree.getSubteeSize()) ))+1;  MarkableBaseNode found = doGetRandomNode( pos, root, markMask, forbiddenTree ); if( found == null && markMask > 0 ) found=doGetRandomNode(SCAN_UNMARKED,root,markMask, forbiddenTree );
  public MarkableBaseNode getRandomNode( MarkableBaseNode root, boolean isUnmarked,     MarkableBaseNode forbiddenTree ) {    int pos = (int) (rnd.nextDouble() * (root.getSubteeSize() - forbiddenTree.getSubteeSize() ));    MarkableBaseNode found = doGetRandomNode( pos, root, isUnmarked, forbiddenTree );    if( found == null && isUnmarked )      found=doGetRandomNode(SCAN_UNMARKED,root,isUnmarked, forbiddenTree ); // Unmarked scann reached end of tree, start from top// Forbiddentreecheck    MarkableBaseNode _n = found;    while( _n != null ) {      if( _n == forbiddenTree )        throw new IllegalStateException("found in forbidden tree");      _n = (MarkableBaseNode) _n.getParent();    }// endcheck    return found;  }