Calculates various statistics about the code hierarchy including the total number of themes and codes, maximum depth, and distribution of codes across themes. Now also accounts for codes not associated with any theme.
calculate_hierarchy_stats(node, all_codes = NULL)A list containing hierarchy statistics:
total_themes: Total number of themes in the hierarchy (excluding root)
total_codes: Total number of codes in the hierarchy
unassigned_codes: Number of codes not in the hierarchy
max_depth: Maximum depth of the hierarchy tree
codes_per_theme: List showing number of codes in each theme
average_codes_per_theme: Average number of codes per theme
Root node of the hierarchy tree
Character vector of all codes in the application