Refactor is_same+unwrap to as_ref+map_or.