implement find_containing_env