 
         return nodes[0..<sliceIndex]
     }
-
-
-    /// Finds the Deepest node that can be merged "Right to Left", and returns the Left / Right matching touple, if any.
-    ///
-    private func findMergeableNodes(left: [ElementNode], right: [ElementNode]) -> [MergeablePair]? {
-        var currentIndex = 0
-        var matching = [MergeablePair]()
-
-        while currentIndex < left.count && currentIndex < right.count {
-            let left = left[currentIndex]
-            let right = right[currentIndex]
-
-            guard left.canMergeChildren(of: right) else {
-                break
-            }
-
-            let pair = MergeablePair(left: left, right: right)
-            matching.append(pair)
-            currentIndex += 1
-        }
-
-        return matching.isEmpty ? nil : matching
-    }
 }
 
 

            previous = consolidated
        }

        NSLog("Sorted:\n\(output)")

        return output
    }


            return [node]
        }
    }


    /// Finds the Deepest node that can be merged "Right to Left", and returns the Left / Right matching touple, if any.
    ///
    func findMergeableNodes(left: [ElementNode], right: [ElementNode], blocklevelEnforced: Bool = true) -> [MergeablePair]? {
        var currentIndex = 0
        var matching = [MergeablePair]()

        while currentIndex < left.count && currentIndex < right.count {
            let left = left[currentIndex]
            let right = right[currentIndex]

            guard left.canMergeChildren(of: right, blocklevelEnforced: blocklevelEnforced) else {
                break
            }

            let pair = MergeablePair(left: left, right: right)
            matching.append(pair)
            currentIndex += 1
        }

        return matching.isEmpty ? nil : matching
    }
}


