public static boolean isEstablishedAtAltitude(Track track, Instant queryTime, Duration duration) {
        TimeWindow window = TimeWindow.of(queryTime.minus(duration), queryTime);
        NavigableSet<Point> recentPoints = (NavigableSet<Point>) track.subset(window);

        if (recentPoints.isEmpty()) {
            return false;
        }

        List<Distance> recentDistances = recentPoints
            .stream()
            .map(Point::altitude)
            .collect(toList());

        Distance min = min(recentDistances);
        Distance max = max(recentDistances);
        Distance altitudeRange = max.minus(min);

        boolean allAltitudesWithin100Feet = altitudeRange.isLessThanOrEqualTo(Distance.ofFeet(100));
        boolean atLeastTwoPoints = recentPoints.size() >= 2;

        return atLeastTwoPoints && allAltitudesWithin100Feet;
    }
@Test
    public void testIsEstablishedAtAltitude_outOfBoundsQueriesDoNotGenerateExceptions() {

        Track track = makeTrackFromNopData(getResourceFile("Track2.txt"));

        Duration fiveSeconds = Duration.ofSeconds(5);

        Instant timeBeforeTrackExists = track.startTime().minusSeconds(1_000);

        assertDoesNotThrow(
            () ->  isEstablishedAtAltitude(track, timeBeforeTrackExists, fiveSeconds)
        );
    }