docs: private static boolean linearPathWithinLinearPath_(MultiPath multipathA,
  			MultiPath multipathB, double tolerance, boolean bEnforceOrientation) {
  		boolean bWithin = true;
  		double[] scalarsA = new double[2];
  		double[] scalarsB = new double[2];
  
  		int ievent = 0;
  		AttributeStreamOfInt32 eventIndices = new AttributeStreamOfInt32(0);
  		RelationalOperations relOps = new RelationalOperations();
  		OverlapComparer overlapComparer = new OverlapComparer(relOps);
  		OverlapEvent overlapEvent;
  
  		Envelope2D env_a = new Envelope2D();
  		Envelope2D env_b = new Envelope2D();
  		Envelope2D envInter = new Envelope2D();
  		multipathA.queryEnvelope2D(env_a);
  		multipathB.queryEnvelope2D(env_b);
  		env_a.inflate(tolerance, tolerance);
  		env_b.inflate(tolerance, tolerance);
  		envInter.setCoords(env_a);
  		envInter.intersect(env_b);
  
  		SegmentIteratorImpl segIterA = ((MultiPathImpl) multipathA._getImpl())
  				.querySegmentIterator();
  		SegmentIteratorImpl segIterB = ((MultiPathImpl) multipathB._getImpl())
  				.querySegmentIterator();
  
  		QuadTreeImpl qtB = null;
  		QuadTreeImpl quadTreeB = null;
          QuadTreeImpl quadTreePathsB = null;
  
  		GeometryAccelerators accel = ((MultiPathImpl) multipathB._getImpl())
  				._getAccelerators();
  
  		if (accel != null) {
  			quadTreeB = accel.getQuadTree();
              quadTreePathsB = accel.getQuadTreeForPaths();
  			if (quadTreeB == null) {
  				qtB = InternalUtils.buildQuadTree(
  						(MultiPathImpl) multipathB._getImpl(), envInter);
  				quadTreeB = qtB;
  			}
  		} else {
  			qtB = InternalUtils.buildQuadTree(
  					(MultiPathImpl) multipathB._getImpl(), envInter);
  			quadTreeB = qtB;
  		}
  
  		QuadTreeImpl.QuadTreeIteratorImpl qtIterB = quadTreeB.getIterator();
  
          QuadTreeImpl.QuadTreeIteratorImpl qtIterPathsB = null;
          if (quadTreePathsB != null)
              qtIterPathsB = quadTreePathsB.getIterator();
  
  		while (segIterA.nextPath()) {
  			while (segIterA.hasNextSegment()) {
  				boolean bStringOfSegmentAsCovered = false;
  
  				Segment segmentA = segIterA.nextSegment();
  				segmentA.queryEnvelope2D(env_a);
  
  				if (!env_a.isIntersecting(envInter)) {
  					return false; // bWithin = false
  				}
  
                  if (qtIterPathsB != null) {
                      qtIterPathsB.resetIterator(env_a, tolerance);
  
                      if (qtIterPathsB.next() == -1) {
                          bWithin = false;
                          return false;
                      }
                  }
  
  				double lengthA = segmentA.calculateLength2D();
  
  				qtIterB.resetIterator(segmentA, tolerance);
  
  				for (int elementHandleB = qtIterB.next(); elementHandleB != -1; elementHandleB = qtIterB
  						.next()) {
  					int vertex_b = quadTreeB.getElement(elementHandleB);
  					segIterB.resetToVertex(vertex_b);
  					Segment segmentB = segIterB.nextSegment();
  
  					int result = segmentA.intersect(segmentB, null, scalarsA,
  							scalarsB, tolerance);
  
  					if (result == 2 && (!bEnforceOrientation || scalarsB[0] <= scalarsB[1])) {
  						double scalar_a_0 = scalarsA[0];
  						double scalar_a_1 = scalarsA[1];
  						double scalar_b_0 = scalarsB[0];
  						double scalar_b_1 = scalarsB[1];
  
  						// Performance enhancement for nice cases where
  						// localization occurs. Increment segIterA as far as we
  						// can while the current segmentA is covered.
  						if (scalar_a_0 * lengthA <= tolerance
  								&& (1.0 - scalar_a_1) * lengthA <= tolerance) {
  							bStringOfSegmentAsCovered = true;
  
  							ievent = 0;
  							eventIndices.resize(0);
  							relOps.m_overlap_events.clear();
  
  							int ivertex_a = segIterA.getStartPointIndex();
  							boolean bSegmentACovered = true;
  
  							while (bSegmentACovered) {// keep going while the
  								// current segmentA is
  								// covered.
  								if (segIterA.hasNextSegment()) {
  									segmentA = segIterA.nextSegment();
  									lengthA = segmentA.calculateLength2D();
  
  									result = segmentA.intersect(segmentB, null,
  											scalarsA, scalarsB, tolerance);
  
  									if (result == 2 && (!bEnforceOrientation || scalarsB[0] <= scalarsB[1])) {
  										scalar_a_0 = scalarsA[0];
  										scalar_a_1 = scalarsA[1];
  
  										if (scalar_a_0 * lengthA <= tolerance
  												&& (1.0 - scalar_a_1) * lengthA <= tolerance) {
  											ivertex_a = segIterA
  													.getStartPointIndex();
  											continue;
  										}
  									}
  
  									if (segIterB.hasNextSegment()) {
  										segmentB = segIterB.nextSegment();
  										result = segmentA.intersect(segmentB,
  												null, scalarsA, scalarsB,
  												tolerance);
  
  										if (result == 2 && (!bEnforceOrientation || scalarsB[0] <= scalarsB[1])) {
  											scalar_a_0 = scalarsA[0];
  											scalar_a_1 = scalarsA[1];
  
  											if (scalar_a_0 * lengthA <= tolerance
  													&& (1.0 - scalar_a_1)
  															* lengthA <= tolerance) {
  												ivertex_a = segIterA
  														.getStartPointIndex();
  												continue;
  											}
  										}
  									}
  								}
  
  								bSegmentACovered = false;
  							}
  
  							if (ivertex_a != segIterA.getStartPointIndex()) {
  								segIterA.resetToVertex(ivertex_a);
  								segIterA.nextSegment();
  							}
  
  							break;
  						} else {
  							int ivertex_a = segIterA.getStartPointIndex();
  							int ipath_a = segIterA.getPathIndex();
  							int ivertex_b = segIterB.getStartPointIndex();
  							int ipath_b = segIterB.getPathIndex();
  
  							overlapEvent = OverlapEvent.construct(ivertex_a,
  									ipath_a, scalar_a_0, scalar_a_1, ivertex_b,
  									ipath_b, scalar_b_0, scalar_b_1);
  							relOps.m_overlap_events.add(overlapEvent);
  							eventIndices.add(eventIndices.size());
  						}
  					}
  				}
  
  				if (bStringOfSegmentAsCovered) {
  					continue; // no need to check that segmentA is covered
  				}
  				if (ievent == relOps.m_overlap_events.size()) {
  					return false; // bWithin = false
  				}
  
  				if (eventIndices.size() - ievent > 1) {
  					eventIndices.Sort(ievent, eventIndices.size(),
  							overlapComparer);
  				}
  
  				double lastScalar = 0.0;
  
  				for (int i = ievent; i < relOps.m_overlap_events.size(); i++) {
  					overlapEvent = relOps.m_overlap_events.get(eventIndices
  							.get(i));
  
  					if (overlapEvent.m_scalar_a_0 < lastScalar
  							&& overlapEvent.m_scalar_a_1 < lastScalar) {
  						continue;
  					}
  
  					if (lengthA * (overlapEvent.m_scalar_a_0 - lastScalar) > tolerance) {
  						return false; // bWithin = false
  					} else {
  						lastScalar = overlapEvent.m_scalar_a_1;
  
  						if (lengthA * (1.0 - lastScalar) <= tolerance
  								|| lastScalar == 1.0) {
  							break;
  						}
  					}
  				}
  
  				if (lengthA * (1.0 - lastScalar) > tolerance) {
  					return false; // bWithin = false
  				}
  
  				ievent = 0;
  				eventIndices.resize(0);
  				relOps.m_overlap_events.clear();
  			}
  		}
  
  		return bWithin;
  	}