private void updateMatchedPaths(Connected newERBase) {
    Set<Path> newMatchedPaths = new HashSet<Path>();

    for (Path p : inputStream.getCurrentMatchedPaths()) {

      // if current level is optional -> move through current paths
      if (optional) newMatchedPaths.add(p);

      String lastId = p.getLast();
      Connected lastER = pipeNet.getById(lastId); // last er in the path can be virtual
      if (newERBase.isConnectedTo(lastId)
          || (lastER.isVirtual() && lastER.isConnectedTo(newERBase.getUuid()))) {
        if (!ALLOW_REENTRANCE) { // check for re-entrance
          if (p.contains(newERBase.getUuid())) continue;
        }

        p = p.clone();
        p.add(newERBase.getUuid());
        newMatchedPaths.add(p);
      }
    }

    for (Path p : newMatchedPaths) currentMatchedPaths.add(p);

    return;
  }