[BUGFIX] Select available page when changing WS

When changing to another workspaces the currently selected page is not
always available.
This change selects the next available page from the rootline for page
tree and submodules of web module when the current page does not exist
in the workspace.

Change-Id: I0502fea3c21515421586403a41f5c696ffc0d762
Fixes: #37611
Releases: 6.2, 6.1, 6.0, 4.7, 4.5
Reviewed-on: https://review.typo3.org/21110
Reviewed-by: Sascha Egerer
Tested-by: Sascha Egerer
Reviewed-by: Timo Webler
Tested-by: Timo Webler
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring