docstr: connect to peers.  `peers` will be a dict of 4-tuples, keyed by name.
  {peer : (ident, addr, pub_addr, location)}
  where peer is the name, ident is the XREP identity, addr,pub_addr are the
docstr_tok: ["connect","to","peers",".","`","peers","`","will","be","a","dict","of","4-tuples",",","keyed","by","name",".","{","peer",":","(","ident",",","addr",",","pub_addr",",","location",")","}","where","peer","is","the","name",",","ident","is","the","XREP","identity",",","addr",",","pub_addr","are","the"]
code: def connect(self, peers, btree, pub_url, root_id=0):
      """connect to peers.  `peers` will be a dict of 4-tuples, keyed by name.
      {peer : (ident, addr, pub_addr, location)}
      where peer is the name, ident is the XREP identity, addr,pub_addr are the
      """
  
      # count the number of children we have
      self.nchildren = list(btree.values()).count(self.id)
  
      if self.root:
          return  # root only binds
  
      root_location = peers[root_id][-1]
      self.sub.connect(disambiguate_dns_url(pub_url, root_location))
  
      parent = btree[self.id]
  
      tree_url, location = peers[parent]
      self.upstream.connect(disambiguate_dns_url(tree_url, location))
  
imports: import re
  import socket
  from functools import reduce
  import zmq
  from ipyparallel.serialize import deserialize_object, serialize_object
  from ipyparallel.util import disambiguate_url
label_desc: Use image node_id 4 for calling the BinaryTreeCommunicator obj's underlying member method code with example usage: obj.connect(peers, btree, pub_url, root_id) without return types