def node_boundary(G, nbunch1, nbunch2=None):
    """Return the node boundary.

    The node boundary is all nodes in the edge boundary of a given
    set of nodes that are in the set.

    Parameters
    ----------
    G : graph
      A networkx graph

    nbunch1 : list, container
       Interior node set

    nbunch2 : list, container
       Exterior node set.  If None then it is set to all of the
       nodes in G not in nbunch1.

    Returns
    -------
    nlist : list
       List of nodes.

    Notes
    -----
    Nodes in nbunch1 and nbunch2 that are not in G are ignored.

    nbunch1 and nbunch2 are usually meant to be disjoint,
    but in the interest of speed and generality, that is
    not required here.

    """
    nset1=set(n for n in nbunch1 if n in G)
    bdy=set()
    for n1 in nset1:
        bdy.update(G[n1])
    bdy -= nset1
    if nbunch2 is not None: # else nbunch2 is complement of nbunch1
        bdy &= set(nbunch2)
    return list(bdy)