Correct way to use GH_Structure.DuplicateCast

Hi everyone,

I am trying to use DuplicateCast to convert a GH_Structure containing GH_Number to its parent type IGH_Goo.
The issue I am facing is that the returned tree contains the correct number of branches, but they are empty. Here is my code:

GH_Structure<GH_Number> tree = null;
if (!DA.GetDataTree(attribute.mFullName, out tree)) return;
GH_Structure<IGH_Goo> convertedTree = tree.DuplicateCast<IGH_Goo>(IGHGooConverter);

With IGHGooConverter:

public static IGH_Goo IGHGooConverter(GH_Number obj) {
    return obj;
}

Found that in this old post

Am I using DuplicateCast correctly?

Thanks for your help,
Loris

If I can believe the disassembly the code seem to iterate over an empty list, believing it is the actual data for a given branch:

I can’t say for sure if that is really what happens, but that is what the disassembly shows. I’m quite certain that the two new lists are of size 0