topenv(envir = parent.frame(),
       matchThisEnv = getOption("topLevelEnvironment"))
| envir | an environment to start the search. | 
| matchThisEnv | an environment. If this environment is found during the search, it is returned. | 
# these enviroments are defined as top level environments
identical(topenv(globalenv()),globalenv())
identical(topenv(baseenv()),baseenv())
identical(topenv(getNamespace("base")),getNamespace("base"))
# search for first top-level environment
e1 <- new.env(parent=baseenv())
e2 <- new.env(parent=e1)
identical(topenv(e2), baseenv())
# specify matchThisEnv to stop the search
identical(topenv(e2, matchThisEnv=e1), e1)