def drop_internal_nodes(network):
    """
    Given a network from `build_monodirectional_network`, drop nodes that are
    "internal" to a segment. Nodes are internal if their edges only connect it
    with a single segment. Doesn't drop nodes that are dead_ends.

    Drops the nodes in place and returns a list of the nodes that were dropped.

    Parameters
    ----------
    network: nx.DiGraph
        A graph created by `build_monodirectional_network`.

    Returns
    -------
    list of nodes that were dropped from the network.
    """
    to_remove = []

    for obj in network:
        if 'node' in obj:
            if (
                # Not a dead end
                (len(network[obj]) > 0) and
                (len(list(network.predecessors(obj))) > 0) and

                # Comes and goes to the same physical ID
                (len(set(network[obj]).union(network.predecessors(obj))) == 1)
            ):
                to_remove.append(obj)

    for obj in to_remove:
        network.remove_node(obj)

    return to_remove