code: def gateway_by_type(self, type=None, on_network=None):  # @ReservedAssignment
      
      gateways = route_level(self, 'gateway')
      if not type:
          for gw in gateways:
              yield gw
      else:
          for node in gateways:
              #TODO: Change to type == node.related_element_type when
              # only supporting SMC >= 6.4
              if type == node.routing_node_element.typeof:
                  # If the parent is level interface, this is a tunnel interface
                  # where the gateway is bound to interface versus network
                  parent = node._parent
                  if parent.level == 'interface':
                      interface = parent
                      network = None
                  else:
                      network = parent
                      interface = network._parent
                  
                  if on_network is not None:
                      if network and network.ip == on_network:
                          yield (interface, network, node)
                  else:
                      yield (interface, network, node)
docs: Return gateways for the specified node. You can also
      specify type to find only gateways of a specific type.
      Valid types are: bgp_peering, netlink, ospfv2_area.
      
      :param RoutingNode self: the routing node to check
      :param str type: bgp_peering, netlink, ospfv2_area
      :param str on_network: if network is specified, should be CIDR and
          specifies a filter to only return gateways on that network when
          an interface has multiple
      :return: tuple of RoutingNode(interface,network,gateway)
      :rtype: list