docs: private static int updateRiaAndTerminalMemory( LeftTupleSource lt,
                                                      LeftTupleSource originalLt,
                                                      SegmentMemory smem,
                                                      InternalWorkingMemory wm,
                                                      boolean fromPrototype,
                                                      int nodeTypesInSegment ) {
  
          nodeTypesInSegment = checkSegmentBoundary(lt, wm, nodeTypesInSegment);
  
          for (LeftTupleSink sink : lt.getSinkPropagator().getSinks()) {
              if (NodeTypeEnums.isLeftTupleSource(sink)) {
                  nodeTypesInSegment = updateRiaAndTerminalMemory((LeftTupleSource) sink, originalLt, smem, wm, fromPrototype, nodeTypesInSegment);
              } else if (sink.getType() == NodeTypeEnums.RightInputAdaterNode) {
                  // Even though we don't add the pmem and smem together, all pmem's for all pathend nodes must be initialized
                  RiaNodeMemory riaMem = (RiaNodeMemory) wm.getNodeMemory((MemoryFactory) sink);
                  // Only add the RIANode, if the LeftTupleSource is part of the RIANode subnetwork
                  if (inSubNetwork((RightInputAdapterNode) sink, originalLt)) {
                      PathMemory pmem = riaMem.getRiaPathMemory();
                      smem.addPathMemory( pmem );
                      if (smem.getPos() < pmem.getSegmentMemories().length) {
                          pmem.setSegmentMemory( smem.getPos(), smem );
                      }
  
                      if (fromPrototype) {
                          ObjectSink[] nodes = ((RightInputAdapterNode) sink).getObjectSinkPropagator().getSinks();
                          for ( ObjectSink node : nodes ) {
                              // check if the SegmentMemory has been already created by the BetaNode and if so avoid to build it twice
                              if ( NodeTypeEnums.isLeftTupleSource(node) && wm.getNodeMemory((MemoryFactory) node).getSegmentMemory() == null )  {
                                  restoreSegmentFromPrototype(wm, (LeftTupleSource) node, nodeTypesInSegment);
                              }
                          }
                      } else if ( ( pmem.getAllLinkedMaskTest() & ( 1L << pmem.getSegmentMemories().length ) ) == 0 ) {
                          // must eagerly initialize child segment memories
                          ObjectSink[] nodes = ((RightInputAdapterNode) sink).getObjectSinkPropagator().getSinks();
                          for ( ObjectSink node : nodes ) {
                              if ( NodeTypeEnums.isLeftTupleSource(node) )  {
                                  createSegmentMemory( (LeftTupleSource) node, wm );
                              }
                          }
                      }
                  }
              } else if (NodeTypeEnums.isTerminalNode(sink)) {
                  PathMemory pmem = (PathMemory) wm.getNodeMemory((MemoryFactory) sink);
                  smem.addPathMemory(pmem);
                  // this terminal segment could have been created during a rule removal with the only purpose to be merged
                  // with the former one and in this case doesn't have to be added to the the path memory
                  if (smem.getPos() < pmem.getSegmentMemories().length) {
                      pmem.setSegmentMemory( smem.getPos(), smem );
                      if (smem.isSegmentLinked()) {
                          // not's can cause segments to be linked, and the rules need to be notified for evaluation
                          smem.notifyRuleLinkSegment(wm);
                      }
                      checkEagerSegmentCreation(sink.getLeftTupleSource(), wm, nodeTypesInSegment);
                  }
              }
          }
          return nodeTypesInSegment;
      }