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;
  }
  private Set<Connected> getERByPreviousIds(Set<String> previousIds) {
    Set<Connected> matchedERs = new HashSet<Connected>();

    for (Connected er : currentERNetwork) {
      for (String previousId : previousIds) {
        if (er.isConnectedTo(previousId)) {

          // check for useOnly
          if (!useOnlyAttrMap.isEmpty()) {
            if (isMatch(er, this.useOnlyAttrMap, true)) {
              matchedERs.add(er);
              break;
            }
          } else if (!ignoreAttrMap.isEmpty()) {
            // check for ignore match
            if (!isMatch(er, this.ignoreAttrMap, false)) {
              matchedERs.add(er);
              break;
            }
          } else {
            // no use-only or ignore filters -> just add it
            matchedERs.add(er);
            break;
          }
        } // if (er.isConnectedTo(previousId))
      }
    } // for (ERBase er : currentERNetwork.getERBases())

    return matchedERs;
  }