$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$storeManager = $objectManager->get('MagentoStoreModelStoreManagerInterface');
$rootCatNode = $data['catalog'][0];
$websiteId = $storeManager->getWebsite()->getWebsiteId();
$store = $storeManager->getStore();
$storeId = $store->getStoreId();
$rootNodeId = $store->getRootCategoryId();
$rootCat = $objectManager->get('MagentoCatalogModelCategory');
$cat_info = $rootCat->load($rootCatNode);
echo "";
foreach($data['catalognew'] as $newdata){
$getCatData = $objectManager->create('MagentoCatalogModelCategory')->load($newdata);
$categoryFactory = $objectManager->get('MagentoCatalogModelCategoryFactory');
// if($getCatData->getLevel()==2) {
$categoryTmp = $categoryFactory->create();
$categoryTmp->setName($getCatData->getName());
$categoryTmp->setIsActive(true);
$categoryTmp->setUrlKey(rand(0, 999));
$categoryTmp->setData('description', 'description');
$categoryTmp->setParentId($getCatData->getParentId());
$getCatDatan = $objectManager->create('MagentoCatalogModelCategory')->load($getCatData->getParentId());
$categoryTmp->setStoreId($storeId);
$categoryTmp->setPath($rootCat->getPath());
echo $getCatDatan->getPath();
echo "
";
echo $rootCat->getPath();
$categoryTmp->save();
}