S01. Initialize a REPLACE-CSID container in full SID format equal to the first SID in the series S02. Push the REPLACE-CSID container onto the compressed SID list S03. Initialize a new REPLACE-CSID container in packed format if there are more than one SIDs and initialize the remaining capacity of the REPLACE-CSID container to 128 bits S04. For each subsequent SID in the uncompressed SID list { S05. Set S to the current SID in the uncompressed SID list S06. If ComCheck(First SID, S) { S07. If the LNFL of S is lower than or equal to the remaining capacity of the REPLACE-CSID container { S08. Copy the Locator-Node and Function of S to the least significant remaining bits of the REPLACE-CSID container and decrement the remaining capacity by LNFL // Note S09. } Else { S10. Push the REPLACE-CSID container onto the compressed SID list S11. Initialize a new REPLACE-CSID container in packed format with all bits set to 0 S12. Copy the Locator-Node and Function of S to the least significant remaining bits of the REPLACE-CSID container and decrement the remaining capacity by LNFL // Note S13. } S14. If S is not a REPLACE-CSID flavor SID, then break S15. } Else { S16. Break S17. } // End If S18. } // End For S19. Push the REPLACE-CSID container (if it is not empty) onto the compressed SID list