Buggy code:
public class PolygonsSet extends AbstractRegion < Euclidean2D , Euclidean1D > { private static final double DEFAULT_TOLERANCE = 1.0E-10 ; private Vector2D [ ] [ ] vertices ; public PolygonsSet ( final double tolerance ) { } public PolygonsSet ( final BSPTree < Euclidean2D > tree , final double tolerance ) { } public PolygonsSet ( final Collection < SubHyperplane < Euclidean2D > > boundary , final double tolerance ) { } public PolygonsSet ( final double xMin , final double xMax , final double yMin , final double yMax , final double tolerance ) { } public PolygonsSet ( final double hyperplaneThickness , final Vector2D ... vertices ) { } @ Deprecated public PolygonsSet ( ) { } @ Deprecated public PolygonsSet ( final BSPTree < Euclidean2D > tree ) { } @ Deprecated public PolygonsSet ( final Collection < SubHyperplane < Euclidean2D > > boundary ) { } @ Deprecated public PolygonsSet ( final double xMin , final double xMax , final double yMin , final double yMax ) { } private static Line [ ] boxBoundary ( final double xMin , final double xMax , final double yMin , final double yMax , final double tolerance ) { } private static BSPTree < Euclidean2D > verticesToTree ( final double hyperplaneThickness , final Vector2D ... vertices ) { } private static void insertEdges ( final double hyperplaneThickness , final BSPTree < Euclidean2D > node , final List < PolygonsSet . Edge > edges ) { } private static class Vertex { private final Vector2D location ; private PolygonsSet . Edge incoming ; private PolygonsSet . Edge outgoing ; private final List < Line > lines ; public Vertex ( final Vector2D location ) { } public Vector2D getLocation ( ) { } public void bindWith ( final Line line ) { } public Line sharedLineWith ( final PolygonsSet . Vertex vertex ) { } public void setIncoming ( final PolygonsSet . Edge incoming ) { } public PolygonsSet . Edge getIncoming ( ) { } public void setOutgoing ( final PolygonsSet . Edge outgoing ) { } public PolygonsSet . Edge getOutgoing ( ) { } } private static class Edge { private final PolygonsSet . Vertex start ; private final PolygonsSet . Vertex end ; private final Line line ; private BSPTree < Euclidean2D > node ; public Edge ( final PolygonsSet . Vertex start , final PolygonsSet . Vertex end , final Line line ) { } public PolygonsSet . Vertex getStart ( ) { } public PolygonsSet . Vertex getEnd ( ) { } public Line getLine ( ) { } public void setNode ( final BSPTree < Euclidean2D > node ) { } public BSPTree < Euclidean2D > getNode ( ) { } public PolygonsSet . Vertex split ( final Line splitLine ) { } } @ Override public PolygonsSet buildNew ( final BSPTree < Euclidean2D > tree ) { } @ Override protected void computeGeometricalProperties ( ) { } public Vector2D [ ] [ ] getVertices ( ) { } private List < PolygonsSet . ComparableSegment > followLoop ( final AVLTree < ComparableSegment > . Node node , final org . apache . commons . math3 . geometry . partitioning . utilities . AVLTree < PolygonsSet . ComparableSegment > sorted ) { final ArrayList < PolygonsSet . ComparableSegment > loop = new ArrayList < PolygonsSet . ComparableSegment > ( ) ; PolygonsSet . ComparableSegment segment = node . getElement ( ) ; loop . add ( segment ) ; final Vector2D globalStart = segment . getStart ( ) ; Vector2D end = segment . getEnd ( ) ; node . delete ( ) ; final boolean open = ( segment . getStart ( ) ) == null ; <START_BUG> while ( ( end != null ) && ( open || ( ( globalStart . distance ( ( ( Point < Euclidean2D > ) ( end ) ) ) ) > 1.0E-10 ) ) ) { <END_BUG> AVLTree < ComparableSegment > . Node selectedNode = null ; PolygonsSet . ComparableSegment selectedSegment = null ; double selectedDistance = Double . POSITIVE_INFINITY ; final PolygonsSet . ComparableSegment lowerLeft = new PolygonsSet . ComparableSegment ( end , ( - 1.0E-10 ) , ( - 1.0E-10 ) ) ; final PolygonsSet . ComparableSegment upperRight = new PolygonsSet . ComparableSegment ( end , ( + 1.0E-10 ) , ( + 1.0E-10 ) ) ; for ( AVLTree < ComparableSegment > . Node n = sorted . getNotSmaller ( lowerLeft ) ; ( n != null ) && ( ( n . getElement ( ) . compareTo ( upperRight ) ) <= 0 ) ; n = n . getNext ( ) ) { segment = n . getElement ( ) ; final double distance = end . distance ( ( ( Point < Euclidean2D > ) ( segment . getStart ( ) ) ) ) ; if ( distance < selectedDistance ) { selectedNode = n ; selectedSegment = segment ; selectedDistance = distance ; } } if ( selectedDistance > 1.0E-10 ) { return null ; } end = selectedSegment . getEnd ( ) ; loop . add ( selectedSegment ) ; selectedNode . delete ( ) ; } if ( ( ( loop . size ( ) ) == 2 ) && ( ! open ) ) { return null ; } if ( ( end == null ) && ( ! open ) ) { throw new MathInternalError ( ) ; } return loop ; } private static class ComparableSegment extends Segment implements Comparable < PolygonsSet . ComparableSegment > { private OrderedTuple sortingKey ; public ComparableSegment ( final Vector2D start , final Vector2D end , final Line line ) { } public ComparableSegment ( final Vector2D start , final double dx , final double dy ) { } public int compareTo ( final PolygonsSet . ComparableSegment o ) { } @ Override public boolean equals ( final Object other ) { }

Fix:
while ( ( end != null ) && ( open || ( ( globalStart . distance ( ( ( Point < Euclidean2D > ) ( end ) ) ) ) > ( getTolerance ( ) ) ) ) ) {