Only open submodule after checking parent path

Previously an infinite loop of open calls were possible since
the path check to the parent repository was done after opening
which would never occur if the same repository path was used each
time.

Now opening the repository is separate from opening its submodules.
1.2.1