code: def neighborhood(self, node, degree=4):
      
      assert self.by_name[node.name] == node
      already_visited = frontier = set([node.name])
      for _ in range(degree):
        neighbor_names = set()
        for node_name in frontier:
          outgoing = set(n.name for n in self.by_input[node_name])
          incoming = set(self.by_name[node_name].input)
          neighbor_names |= incoming | outgoing
        frontier = neighbor_names - already_visited
        already_visited |= neighbor_names
      return [self.by_name[name] for name in already_visited]
docs: Am I really handcoding graph traversal please no