code: def calculate_predict_hierarchical_importance(
      aspect,
      new_observation,
      type="default",
      N=2000,
      B=25,
      sample_method="default",
      f=2,
      processes=1,
      random_state=None,
  ):
      result_df = pd.DataFrame()
      cutting_heights = aspect.linkage_matrix[:, 2]
  
      aspects_list_previous = aspect.get_aspects(h=2)
      set_aspects_list_previous = {
          tuple(aspect) for aspect in aspects_list_previous.values()
      }
  
      for i in range(len(cutting_heights)):
          aspects_list_current = aspect.get_aspects(
              1 - cutting_heights[i]
          )
          set_aspects_list_current = {
              tuple(aspect) for aspect in aspects_list_current.values()
          }
  
          set_diff = (
              set_aspects_list_current - set_aspects_list_previous
          )
          if not bool(set_diff):
              continue
          lastly_merged = list(set_diff)
          lastly_merged = [list(el) for el in lastly_merged]
  
          if type == "default":
              current_aspects_importance = (
                  calculate_predict_aspect_importance(
                      explainer=aspect.explainer,
                      new_observation=new_observation,
                      variable_groups=aspects_list_current,
                      N=N,
                      n_aspects=None,
                      sample_method=sample_method,
                      f=f,
                      random_state=random_state,
                  )
              )
          else:
              current_aspects_importance = (
                  calculate_shap_predict_aspect_importance(
                      explainer=aspect.explainer,
                      new_observation=new_observation,
                      variable_groups=aspects_list_current,
                      N=N,
                      B=B,
                      processes=processes,
                      random_state=random_state,
                  )
              )
  
          ind = [
              elem in lastly_merged
              for elem in current_aspects_importance.variable_names
          ]
          lastly_merged_aspect_importance = (
              current_aspects_importance.loc[ind]
          )
  
          result_df = pd.concat(
              [result_df, lastly_merged_aspect_importance]
          )
          set_aspects_list_previous = set_aspects_list_current
  
      result_df = result_df.drop("aspect_name", axis=1).reset_index(
          drop=True
      )
      return result_df
  
file_path: DALEX/python/dalex/dalex/aspect/_predict_triplot/utils.py
imports: import numpy
  import pandas
  import itertools
  from copy import deepcopy
  import re
  from dalex.aspect._predict_aspect_importance.utils import calculate_predict_aspect_importance, calculate_shap_predict_aspect_importance
label_desc: Use image node_id 1 for calling a global function with example usage: calculate_predict_hierarchical_importance(aspect, new_observation, type, N, B, sample_method, f, processes, random_state) and returns: result_df