Small memory allocations are a bottleneck when drawing large node trees. Avoid them by passing the socket index in the whole tree and getting the tree from the context rather than allocating structs for the tree, node, and socket. The performance improvement will be a few percent at most.