Encode segment in NodeId.