anchor.diff:      %% Note: order of evaluation below is important (the exprs of `andalso'):
       %% Messages are present in Occurrences only if they are sub-messages
       can_occur_as_sub_msg(MsgName, AnRes) andalso
  -        lists:member(optional, dict:fetch(MsgName, Occurrences)).
  +        case dict:find(MsgName, Occurrences) of
  +            error       -> false; % likely only referenced from a oneof
  +            {ok, MOccs} -> lists:member(optional, MOccs)
  +        end.
   
   format_field_skippers(MsgName, AnRes) ->
       SkipVarintFnName = mk_fn(skip_varint_, MsgName),
  
positive.code: %% Loop over all message fields, including oneof-fields
  %% Call Fun for all #?gpb_fields{}, skip over non-msg defs
  fold_msg_fields(Fun, InitAcc, Defs) ->
      lists:foldl(
        fun({{msg, MsgName}, Fields}, Acc) ->
                FFun = fun(Field, FAcc) -> Fun(MsgName, Field, FAcc) end,
                fold_msgdef_fields(FFun, Acc, Fields);
           (_Def, Acc) ->
                Acc
        end,
        InitAcc,
        Defs).
  
  fold_msgdef_fields(Fun, InitAcc, Fields) ->
      lists:foldl(
        fun(#?gpb_field{}=Field, Acc) ->
                Fun(Field, Acc);
           (#gpb_oneof{fields=OFields}, Acc) ->
                lists:foldl(fun(OField, OAcc) -> Fun(OField, OAcc) end,
                            Acc,
                            OFields)
        end,
  
negative.code:       Defs).
  
  find_msg_occurrences(Defs) ->
      %% Don't "count" occurrences inside oneof fields
      fold_msg_fields_o(
        fun(_MsgName, #?gpb_field{type=Type, occurrence=Occ}, false, Acc) ->
                case Type of
                    {msg,SubMsgName} ->
                        add_occurrence(SubMsgName, Occ, Acc);
                    _Other ->
                        Acc
                end;
           (_MsgName, #?gpb_field{}, {true, _CFName}, Acc) ->
                Acc
        end,
        dict:new(),
        Defs).
  
  add_occurrence(MsgName, Occurrence, D) ->
      case dict:find(MsgName, D) of
  