Does the JVM optimize this?

Let's suppose we have a tree of nodes (i.e. GameStates). Each frame, we call update on the the tree nodes.

However, a branch of the tree has no code on the update method, or there is code in only a few leaves. Is the JIT compiler clever enough as to replace the tree walking code with something that directly runs update() on the necessary objects?

I don't think so. The compiler doesn't even inline much in the client JVM, so chances that it does this kind of advanced inlining are zero.

Anyway I don't think it matters much, GameState update only gets called a few times per frame. You should worry more about things like animation skinning code or scene rendering optimizations than this.

BTW jjmontes, if you want the JVM to optimize your code more, you should run it with the "server" VM, it takes longer to load your application but in the end it runs faster. Just pass the "-server" parameter as VM argument.