public static <T> TreeSet<Point<T>> subset(TimeWindow subsetWindow, NavigableSet<Point<T>> points) {
        checkNotNull(subsetWindow);
        checkNotNull(points);

        //if the input collection is empty the output collection will be empty to
        if (points.isEmpty()) {
            return newTreeSet();
        }

        Point<T> midPoint = Point.<T>builder()
            .time(subsetWindow.instantWithin(.5))
            .latLong(0.0, 0.0)
            .build();

        /*
         * Find exactly one point in the actual Track, ideally this point will be in the middle of
         * the time window
         */
        Point<T> aPointInTrack = points.floor(midPoint);
        if (aPointInTrack == null) {
            aPointInTrack = points.ceiling(midPoint);
        }

        TreeSet<Point<T>> outputSubset = newTreeSet();

        //given a starting point....go up until you hit startTime.
        NavigableSet<Point<T>> headset = points.headSet(aPointInTrack, true);
        Iterator<Point<T>> iter = headset.descendingIterator();
        while (iter.hasNext()) {
            Point<T> pt = iter.next();
            if (subsetWindow.contains(pt.time())) {
                outputSubset.add(pt);
            }

            if (pt.time().isBefore(subsetWindow.start())) {
                break;
            }
        }

        //given a starting point....go down until you hit endTime.
        NavigableSet<Point<T>> tailSet = points.tailSet(aPointInTrack, true);
        iter = tailSet.iterator();

        while (iter.hasNext()) {
            Point<T> pt = iter.next();
            if (subsetWindow.contains(pt.time())) {
                outputSubset.add(pt);
            }

            if (pt.time().isAfter(subsetWindow.end())) {
                break;
            }
        }

        return outputSubset;
    }
@Test
    public void subset_reflectsEndTime() {

        Track<NopHit> t1 = createTrackFromFile(getResourceFile("Track1.txt"));

        //this is the time of 21st point in the track
        Instant endTime = parseNopTime("07/08/2017", "14:10:45.534");

        TimeWindow extractionWindow = TimeWindow.of(EPOCH, endTime);

        TreeSet<Point<NopHit>> subset = subset(extractionWindow, t1.points());

        assertThat(subset, hasSize(21));
        assertThat(subset.last().time(), is(endTime));
    }