The code seems correct, can’t you see parameters from RecursiveNN in .parameters()?
Also, I’d recommend agains caching node.calculate_result if you don’t need it. It will prevent PyTorch from freeing the graph that created node.calculate_result until it is overwriten or manually deleted.