BUG: avoid unnecessary casting  when unstacking index with unused levels
closes #17845
closes #18562

- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18460?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@de42bee`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/18460/graphs/tree.svg?token=eZ4WkYLtcO&src=pr&height=150&width=650)](https://codecov.io/gh/pandas-dev/pandas/pull/18460?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##             master   #18460   +/-   ##
=========================================
  Coverage          ?   91.55%           
=========================================
  Files             ?      147           
  Lines             ?    48827           
  Branches          ?        0           
=========================================
  Hits              ?    44703           
  Misses            ?     4124           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.92% <100%> (?)` | |
| #single | `41.69% <6.25%> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/18460?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/reshape/reshape.py](https://codecov.io/gh/pandas-dev/pandas/pull/18460/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzaGFwZS9yZXNoYXBlLnB5) | `100% <100%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18460?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/18460?src=pr&el=footer). Last update [de42bee...a629b82](https://codecov.io/gh/pandas-dev/pandas/pull/18460?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
 related to #17886 or is that separate? > related to #17886 or is that separate?

Separate - this fix handles specifically the case of unused levels. But I plan to look at #17886 too. @jreback rebased, I also verified that this fixes #18562 and added a test for that @jreback ping thanks @toobaz  FYI, this caused a 25-30% slowdown in this ASV: http://pandas.pydata.org/speed/pandas/#reshape.SparseIndex.time_unstack I guess it's the ``remove_unused_levels`` call. I can see if (and how) it can be ran on specific levels only. can u create an issue to track this