private function getChildsForLinkedLayer($layerId, $parentLayer)
    {
        $childLayers = C4gMapsModel::findPublishedByPid($layerId);
        $arrLayerData['childs'] = [];
        
        foreach ($childLayers as $childLayer) {
            if ($childLayer->location_type !== "none") {
                // we reached the "bottom" of the tree leaf
                $childData = $this->parseLayer($childLayer);
                $childData['pid'] = $parentLayer->id;
                $arrLayerData['childs'][] = $childData;
                $arrLayerData['hide'] = $parentLayer->data_hidelayer;
            } else {
                $currentChildLayer = $this->parseLayer($childLayer);
                // set correct pid for the contentless element
                $currentChildLayer['pid'] = $parentLayer->id;
                // $childLayer is the acutal existing layer.
                $arrChildData = $this->getChildsForLinkedLayer($childLayer->id, (object) $currentChildLayer);
                $currentChildLayer['childs'] = $arrChildData['childs'];
                $currentChildLayer['content'] = [];
                $currentChildLayer['hasChilds'] = count($currentChildLayer['childs']) > 0;
                $currentChildLayer['childsCount'] = count($currentChildLayer['childs']);
                $arrLayerData['childs'][] = $currentChildLayer;
            }
            
            $arrLayerData['content'] = [];
            $arrLayerData['hasChilds'] = count($arrLayerData['childs']) > 0;
            $arrLayerData['childsCount'] = count($arrLayerData['childs']);
        }
        
        return $arrLayerData;
    }