let
    // Get Speckle Data
    Source = Speckle.GetByUrl("https://latest.speckle.dev/streams/bf8f36b57b/commits/66a4614fd1"),
    
    // We'll reserve the original data for later
    #"Clone Data" = Table.DuplicateColumn(Source, "data", "original data"),
    
    // Expand the data column for the mapping of referenced IDs to objects
    #"Expanded Properties" = Table.ExpandRecordColumn(
        #"Clone Data", "data", {"name", "elements", "collectionType", "displayValue", "definition", "geometry"}
    ),
    #"Expanded Block Geometry Rows" = Table.ExpandListColumn(#"Expanded Properties", "geometry"),
    #"Expanded Geometry Reference ID" = Table.ExpandRecordColumn(
        #"Expanded Block Geometry Rows", "geometry", {"referencedId"}, {"geometry.referencedId"}
    ),
    #"Expanded Block Definition" = Table.ExpandRecordColumn(
        #"Expanded Geometry Reference ID", "definition", {"referencedId"}, {"definition.referencedId"}
    ),
    #"Expanded Layer Children Rows" = Table.ExpandListColumn(#"Expanded Block Definition", "elements"),
    #"Expanded Children Reference ID" = Table.ExpandRecordColumn(
        #"Expanded Layer Children Rows", "elements", {"referencedId"}, {"elements.referencedId"}
    ),
    #"Expanded DisplayValue Rows" = Table.ExpandListColumn(#"Expanded Children Reference ID", "displayValue"),
    #"Expanded DisplayValue Reference ID" = Table.ExpandRecordColumn(
        #"Expanded DisplayValue Rows", "displayValue", {"referencedId"}, {"displayValue.referencedId"}
    ),
    #"Removed Stream/Commit Columns" = Table.RemoveColumns(
        #"Expanded DisplayValue Reference ID", {"Stream URL", "URL Type", "Commit Object ID"}
    ),
    
    // Add a column that rationalises the referenced IDs
    AddReferencedId = Table.AddColumn(
        #"Removed Stream/Commit Columns",
        "Referenced ID",
        each
            if [elements.referencedId] <> null then
                [elements.referencedId]
            else if [definition.referencedId] <> null then
                [definition.referencedId]
            else if [geometry.referencedId] <> null then
                [geometry.referencedId]
            else if [displayValue.referencedId] <> null then
                [displayValue.referencedId]
            else
                null
    ),
    
    // Remove the multiple referencedId columns
    #"Remove All referencedIds" = Table.RemoveColumns(
        AddReferencedId,
        {"elements.referencedId", "definition.referencedId", "geometry.referencedId", "displayValue.referencedId"}
    ),
    
    // Add breadcrumb column
    PathSource = #"Remove All referencedIds",
    
    // A helper function to get parent node's name
    GetParentName = (currentTable as table, currentName as nullable text, objectId as text) as nullable text =>
        let
            // Get parent node
            parentRecord =
                if objectId = null then
                    null
                else
                    Table.SelectRows(currentTable, each [Referenced ID] = objectId){0} ?,
            // Only add layer names to breadcrumb
            parentNameToUse =
                if parentRecord = null then
                    null
                else if parentRecord[collectionType] <> "layer" then
                    null
                else
                    parentRecord[name],
            // Add current name to list of ancestor names
            parentPrefix =
                if parentRecord = null then
                    {}
                else
                    {@GetParentName(currentTable, parentNameToUse, parentRecord[Object ID])},
            ancestorNames = if currentName = null then parentPrefix else {currentName} & parentPrefix,
            // Concatenate ancestor names in reverse order
            newName = if List.Count(ancestorNames) = 0 then null else Text.Combine(List.Reverse(ancestorNames), ".")
        in
            newName,
    
    // Apply the function on each row
    AddBreadcrumbColumn = Table.AddColumn(
        PathSource,
        "Layer Path",
        each
            if [Referenced ID] = null then
                GetParentName(
                    PathSource,
                    if [name] = null then
                        null
                    else if [collectionType] <> "layer" then
                        null
                    else
                        [name],
                    [Object ID]
                )
            else
                "",
        type text
    ),
    #"Filtered Rows" = Table.SelectRows(AddBreadcrumbColumn, each [Layer Path] <> null and [Layer Path] <> ""),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows", {"name", "collectionType", "Referenced ID"}),
    #"Reordered Columns" = Table.ReorderColumns(
        #"Removed Columns", {"Object ID", "speckle_type", "Layer Path", "original data"}
    )
in
    #"Reordered Columns"
