private DataPoint isUnique(Node from,DataPoint point,double tolerance){
  if (logger.isDebugEnabled())   logger.debug("is unique? tolerance " + tolerance + " - "+ point);
  while (from.type == Type.branch) {
    Branch branch=(Branch)from;
    double d=point.get(branch.splitDimension);
    if (Math.abs(d - branch.midPoint) < tolerance) {
      if (logger.isDebugEnabled())       logger.debug("at branch : " + branch + " - recursing both paths");
      DataPoint leftCheck=isUnique(branch.left,point,tolerance);
      DataPoint rightCheck=isUnique(branch.right,point,tolerance);
      if ((leftCheck == null) && (rightCheck == null)) {
        return null;
      }
 else {
        if (leftCheck != null) {
          return leftCheck;
        }
 else {
          return rightCheck;
        }
      }
    }
 else     if (point.getVector()[branch.splitDimension] < branch.midPoint) {
      if (logger.isDebugEnabled())       logger.debug("at branch : " + branch + " - going left");
      from=branch.left;
    }
 else {
      if (logger.isDebugEnabled())       logger.debug("at branch : " + branch + " - going right");
      from=branch.right;
    }
  }
  Leaf leaf=(Leaf)from;
  for (  DataPoint p : leaf.points) {
    for (int i=0; i < p.getDimension(); i++) {
      if (Math.abs(p.get(i) - point.get(i)) >= tolerance) {
        break;
      }
    }
    if (getDistance(p,point) < tolerance) {
      return p;
    }
  }
  return null;
}

private DataPoint isUnique ( Node from , DataPoint point , double tolerance ) { if ( logger . isDebugEnabled ( ) ) logger . debug ( "is unique? tolerance " + tolerance + " - " + point ) ; while ( from . type == Type . branch ) { Branch branch = ( Branch ) from ; double d = point . get ( branch . splitDimension ) ; if ( Math . abs ( d - branch . midPoint ) < tolerance ) { if ( logger . isDebugEnabled ( ) ) logger . debug ( "at branch : " + branch + " - recursing both paths" ) ; DataPoint leftCheck = isUnique ( branch . left , point , tolerance ) ; DataPoint rightCheck = isUnique ( branch . right , point , tolerance ) ; if ( ( leftCheck == null ) && ( rightCheck == null ) ) { return null ; } else { if ( leftCheck != null ) { return leftCheck ; } else { return rightCheck ; } } } else if ( point . getVector ( ) [ branch . splitDimension ] < branch . midPoint ) { if ( logger . isDebugEnabled ( ) ) logger . debug ( "at branch : " + branch + " - going left" ) ; from = branch . left ; } else { if ( logger . isDebugEnabled ( ) ) logger . debug ( "at branch : " + branch + " - going right" ) ; from = branch . right ; } } Leaf leaf = ( Leaf ) from ; for ( DataPoint p : leaf . points ) { for ( int i = 0 ; i < p . getDimension ( ) ; i ++ ) { if ( Math . abs ( p . get ( i ) - point . get ( i ) ) >= tolerance ) { break ; } } if ( getDistance ( p , point ) < tolerance ) { return p ; } } return null ; }
checks whether the given point already exists in the tree with the specified tolerance .
