Environment config file update

Cherry pick of fb2ee3290e2a9a978e93efe043eee776a41ff893

Currently there is an inconsistency with how deep the framework will
look for _ss_environment.php (depending on whether you're installing or
running) and there is also an arbitary limit to how many directories
deep the environment file can be put.

I have some projects that require it to be over 3 levels deep
so felt a more portable and generic loop until hitting the root
directory would be best.