You need to do list management. So, first group the floors by level and flatten the list of levels, then change the old code to the new one. You already have the solution, you just have to put the pieces together.
import clr clr.AddReference("RevitAPI") import Autodesk from Autodesk.Revit.DB import * clr.AddReference("RevitNodes") import Revit clr.ImportExtensions(Revit.GeometryConversion) # The inputs to this node will be stored as a list in the IN variables. floorsByLevel = UnwrapElement(IN) # Place your code below this line. # Get host curves. def GetHostCurves(host): faceRef = HostObjectUtils.GetTopFaces(host) face = floor.GetGeometryObjectFromReference(faceRef) curveLoops = face.GetEdgesAsCurveLoops() curveloopCurves = [[c.ToProtoType() for c in curveloop] for curveloop in curveLoops] return curveloopCurves # Get host curves by level. allCurves =  for level in floorsByLevel: curvesByLevel =  for floor in level: floorCurves = GetHostCurves(floor) curvesByLevel.append(floorCurves) allCurves.append(curvesByLevel) # Assign your output to the OUT variable. OUT = allCurves