How to solve the problem of variable-sized AST as input for a (convolutional) neural network model?
You discovered already one solution for your problem: Zero-Padding.

There are two other common possibilities:


Using Recurrent NNsThis is often used at text processing, where you feed each word one after another into your model.
Using Recursive NNs (I wont recommend this for your use case)This method is also frequently used in word processing, but is more often applied in the semantic analysis of text. You reduce the text to the essential, until it has reached the desired length. However, information is lost in this process.