def check_continuity(links, nodes):
    """
    Check that there aren't any sinks or sources within the network, besides
    inlets and outlets.
    Returns any nodes where continuity is violated.
    """
    problem_nodes = []
    for nid, nidx, nconn in zip(nodes['id'], nodes['idx'], nodes['conn']):
        
        if nid in nodes['outlets'] or nid in nodes['inlets']:
            continue
        
        firstidx = []
        lastidx = []
        for linkid in nconn:
            linkidx = links['id'].index(linkid)
            firstidx.append(links['idx'][linkidx][0])
            lastidx.append(links['idx'][linkidx][-1])
            
        if firstidx[1:] == firstidx[:-1]:
            problem_nodes.append(nid)
        
        if lastidx[1:] == lastidx[:-1]:
            problem_nodes.append(nid)
            
    return problem_nodes