add function to recursively deep-copy environments