public static function termsForBlock($terms, $block)
    {
        foreach ($terms as $term) {
            $title = $term->name;
            if (!empty($block->settings['show_counters'])) {
                $countCacheKey = "t{$term->id}";
                $count = (string)Cache::read($countCacheKey, 'terms_count');
                if ($count == '') {
                    $count = (int)TableRegistry::get('Taxonomy.EntitiesTerms')
                        ->find()
                        ->where(['EntitiesTerms.term_id' => $term->id])
                        ->count();
                    Cache::write($countCacheKey, $count, 'terms_count');
                }
                $title .= " ({$count})";
            }

            $term->set('title', $title);
            $term->set('url', "/find/term:{$term->slug}");

            if (!empty($term->children)) {
                $term->set('expanded', true);
                static::termsForBlock($term->children, $block);
            }
        }
    }