Further reduce the number of database roundtrips in DiffTreeVisitor