def get_type_path(type, type_hierarchy):
    """Gets the type's path in the hierarchy (excluding the root type, like
    owl:Thing).

    The path for each type is computed only once then cached in type_hierarchy,
    to save computation.
    """
    if 'path' not in type_hierarchy[type]:
        type_path = []
        current_type = type
        while current_type in type_hierarchy:
            type_path.append(current_type)
            current_type = type_hierarchy[current_type]['parent']
        type_hierarchy[type]['path'] = type_path
    return type_hierarchy[type]['path']