Consider renaming this to `maybe_extend` (I think that's what it's called in 1.7?). Now there are 2 `extend` functions defined, both with a different signature, where the second uses (but also aliases) the first, and is used afterwards, which is IMHO somewhat confusing.