I'd use a direct cast here instead of `as`, since we already know `reference` is a `DirectReference`. Or maybe move this up top and `continue` if `directRef == null`?