from typing import Dict
from typing import Any


def _expected_hierarchy_size(template: Dict[str, Any]) -> int:
    """
    Compute the expected size of the hierarchy from `template`.

    This function is intended to be invoked recursively.

    :param template: The template that describes the hierarchy

    :return: The total size of all files in the hierarchu
    :rtype: int
    """
    return sum(
        map(
            lambda v: v if isinstance(v, int) else _expected_hierarchy_size(v),
            template.values(),
        )
    )