I added my code to my custom header phtml:
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$catId = 2;
$subCategory = $objectManager->create('Magento\Catalog\Model\Category')->load($catId);
$subCats = $subCategory->getChildrenCategories();
$_helper = $this->helper('Magento\Catalog\Helper\Output');
$hasSubcategories = count($subCats) > 0;
?>
<?php
foreach ($subCats as $subcat) {
$_category = $objectManager->create('Magento\Catalog\Model\Category')->load($subcat->getId());
$subcaturl = $subcat->getUrl();
?>
<li class="level1 dontsplit parent">
<a class="level1 has-children" href="<?php echo $subcaturl . '?cat=' . $_category->getId() ?>"><?php echo $subcat->getName(); ?> (<?php echo $product_count = $_category->getProductCount();?>)</a>
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$object_managertwo = $objectManager->create('Magento\Catalog\Model\Category')->load($subcat->getId());
$subcatslevelthird = $object_managertwo->getChildrenCategories();
?>
<?php if ($subcatslevelthird->count() > 0) { ?>
<ul class="level1">
<?php
foreach ($subcatslevelthird as $subcatthird) {
$_outputhelper = $this->helper('Magento\Catalog\Helper\Output');
$subcaturl = $subcatthird->getUrl();
?>
<li class="level2 dontsplit">
<a class="level2" href="<?php echo $subcaturl ?>"><?php echo $subcatthird->getName(); ?> (<?php echo $subcatthird = $_category->getProductCount();?>)</a>
</li>
<?php } ?>
</ul>
<?php } ?>
</li>
<?php } ?>
all working properly except adding class to li element, i need display class parent - only for if menu has submenu, whats wrong?