Same as for the Stmt* classes, made the JoinNode abstract and created three new classes BranchNode, TableLeafNode, SubqueryLeafNode. At the moment, the subquey node is a true leaf - the child three is kept separately (StmtSubqueryScan) , in the future it may change if we decide to parse to keep parent and child together as a single tree.

I modified all IF statements differentiating between node types to use getNodeType() instead of relying on table index being -1 or vise versa. I hope I found all of them