anchor.diff:  ;
   
   template_peer_rb_stanza
  -:
  -   TEMPLATE PEER name = VARIABLE NEWLINE
  -   (
  -      bgp_tail
  -      | inherit_peer_session_bgp_tail
  -      | no_shutdown_rb_stanza
  -      | remote_as_bgp_tail
  -      | template_peer_address_family
  -   )*
  +locals [java.util.Set<String> addressFamilies] @init {
  +   $addressFamilies = new java.util.HashSet<String>();
  +}
  +:
  +   TEMPLATE PEER name = VARIABLE NEWLINE template_peer_rb_stanza_tail
  +   [$addressFamilies]
  +;
  +
  +template_peer_rb_stanza_tail [java.util.Set<String> addressFamilies]
  +locals [boolean active]
  +:
  +{
  +   if (_input.LT(1).getType() == ADDRESS_FAMILY) {
  +      String addressFamilyString = "";
  +      for (int i = 1, currentType = -1; _input.LT(i).getType() != NEWLINE; i++) {
  +         addressFamilyString += " " + _input.LT(i).getText();
  +      }
  +      if ($addressFamilies.contains(addressFamilyString)) {
  +         $active = false;
  +      }
  +      else {
  +         $addressFamilies.add(addressFamilyString);
  +         $active = true;
  +      }
  +   }
  +   else {
  +      $active = true;
  +   }
  +}
  +
  +   (
  +      {$active}?
  +
  +      (
  +         bgp_tail
  +         | inherit_peer_session_bgp_tail
  +         | no_shutdown_rb_stanza
  +         | remote_as_bgp_tail
  +         | template_peer_address_family
  +      ) template_peer_rb_stanza_tail [$addressFamilies]
  +      |
  +      // intentional blank
  +
  +   )
   ;
   
   template_peer_session_rb_stanza
  
positive.code:    )
     (
        REMOTE_AS asnum = DEC
     )? NEWLINE
     (
        bgp_tail
        | nexus_neighbor_address_family
        | nexus_neighbor_inherit
        | no_shutdown_rb_stanza
        | remote_as_bgp_tail
     )+
  ;
  
  nexus_vrf_rb_stanza
  
negative.code: ;
  
  nexus_neighbor_rb_stanza
  locals [java.util.Set<String> addressFamilies]
  @init {$addressFamilies = new java.util.HashSet<String>();}
  :
     NEIGHBOR
     (
  