Try below code to get category level.
$product = $objectManager->create('Magento\Catalog\Model\Product')->load($itemid);
$cats = $product->getCategoryIds();
$level = 1;
foreach ($cats as $category_id)
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
echo "<br/>categoryid". $category_id;
$collection = $this->_categoryFactory->create()->load($category_id);
echo "</br> Category Name ". $collection->getName();
echo "<br/> Parent category name" . $collection->getParentCategory()->getName();
echo "<br/> Category level" . $collection->getLevel();
$categoryName = $collection->getName();
if($collection->getLevel() > $level) {
$level = $collection->getLevel();
$categoryName = $collection->getName();
}
}
echo $level;$categoryName; exit; // this will be the inner category name
Let me know if you need further help.