Magento 2 – How to programmatically set a new parent for a category?

Magento 2 have the built in category move() method which do the magic of moving the category including updating the parent id, moving the products, set new category URL, clear cache tags, reindex URLs list many more stuff.

Model Class Path :

/<Magento Directory>/vendor/magento/module-catalog/Model/Category.php

BEFORE
AFTER