Good point. I don't think that this code works, though, because there is no way to get a plain RevObject from the RevWalk. I looked at lookupAny(id, int), and it doesn't seem safe to call it and assume that this is a RevBlob or something else, because that ends up adding it to the revwalk.

I've added another method that does something which I think is safer. Let me know what you think.