BUG: Inconsistent conversion of missing column names
- [x] closes #44818
- [x] tests changed / passed
- [x] Ensure all linting tests pass, see [here](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit) for how to run them
- [x] whatsnew entry

Factored out multiple occurances of missing name logic into common method.
DataFrame.to_records() changed to use common method rather than missing value count when filling missing names.
Index.to_frame() left alone for the time being.
```
import pandas as pd
f = pd.DataFrame([1], index=pd.MultiIndex.from_arrays([[2],[3],[4]], names=[None, "a", None]))
```
Old behavior: 
```
>>> pd.DataFrame(f.to_records())
   level_0  a  level_1  0
0        2  3        4  1
```
New  behavior:
```
>>> pd.DataFrame(f.to_records())
   level_0  a  level_2  0
0        2  3        4  1
```
test location makes sense to me Hello @johnzangwill! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:















There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: 

##### Comment last updated at 2021-12-16 13:28:03 UTC > not 100% sold on the location (maybe @jbrockmendel can think of a better one)

I suspect that @jreback was referring to the fact that I factored the logic into core/common.py.
It seemed a good place to me. My method is ref'ed in:
- core/frame.py
- core/indexes/multi.py
- io/pytables.py
- io/sql.py
- io/json/_table_schema.py

and core/common is already imported as `com` into every one.
But if you have a better suggestion... thanks @johnzangwill very nice!