This commit reapplies the category refactoring for PR review purposes.

Revert "Revert to old category module"

This reverts commit d1e68fb4f63e421bc5378ac0704c0581d8a92ab1.
Don't return array, just value. This is how this API was before.
Fix Categories module default data installer.

Since the ID field of CategoryEntity is set to autogenerate, the default
ID in the default data is ignored. As a consequence the prepared data is
not saved as intended. The commit disabled autogenerate for the CategoryEntity
at install time.
Handle when manipulating root category which has a null parent (was 0 in core<=1.3.5)
Prevent data pollution in foreach loop.
Handle condition when nothing was registered, so there's nothing to delete.
Add legacy method to old D2 category entity.
Consolidate old abstract into new for BC
Add some BC methods.
Fix creation of category attributes when creating a new category entry.