The logic was duplicated. Should be no functional changes. The modified function is expected to give same exact results for all inputs. On the "caching last-used track" topic. The code was using last_marker to allow faster lookup of marker closest to the frame. With this change it is still the case since the BKE_tracking_marker_get() does cache last used marker.