need convert the code having nested If conditions to Foreach()

Hi Team,

Could you please help me in converting the following code into Foreach()

if(
          isnull(
            local!region
          ),
          if(
            rule!APN_isEmpty(
              tostring(
                index(
                  local!userlist.data,
                  "regionId",
                  {}
                )
              )
            ),
            if(
              rule!APN_isEmpty(
                tostring(
                  index(
                    local!userlist.data,
                    "lobId",
                    {}
                  )
                )
              ),
              if(
                rule!APN_isEmpty(
                  tostring(
                    index(
                      local!userreg.data,
                      "regionId",
                      {}
                    )
                  )
                ),
                {},
                local!distuserregname
              ),
              null
            ),
            tostring(
              rule!CTR_QE_getRegionNameByRegionId(
                index(
                  local!userlist.data,
                  "regionId",
                  {}
                )
              )
            )
          ),
          local!region
        )

Thanks in advance.

  Discussion posts and replies are publicly visible