@Test
public void removeIsolatedSwitches() throws Exception {

    Network network = NetworkTest1Factory.create();
    VoltageLevel vl = network.getVoltageLevel("voltageLevel1");
    VoltageLevel.NodeBreakerView topo = vl.getNodeBreakerView();
    assertNotNull(vl);
    assertNotNull(topo.getSwitch("load1Disconnector1"));
    assertNotNull(topo.getSwitch("load1Breaker1"));
    assertEquals(5, topo.getSwitchCount());
    // remove the load
    vl.getConnectable("load1", Load.class).remove();
    assertNull(vl.getConnectable("load1", Load.class));
    // remove the switch connected to the bus bar
    topo.removeSwitch("load1Breaker1");
    assertNull(topo.getSwitch("load1Breaker1"));
    // The connecting switch of the load is now isolated: remove it
    NodeBreakerTopology.removeIsolatedSwitches(topo);
    assertNull(topo.getSwitch("load1Disconnector1"));
    assertNull(topo.getSwitch("load1Breaker1"));
    // 2 switches have been removed
    assertEquals(3, topo.getSwitchCount());
}