one of the documented procedures in this installation of the ACS
doc_find_template   filename
What it does:
Finds a master.adp file which can be used as a master template, looking in the directory containing $filename and working our way down the directory tree.
Defined in: /web/philip/packages/acs-core/document-procs.tcl

Source code:

    set path_root [acs_root_dir]

    set start [clock clicks]

    set dir [file dirname $filename]
    while { [string length $dir] > 1 && [string first $path_root $dir] == 0 } {
	# Only look in directories under the path root.
	if { [file isfile "$dir/master.adp"] } {
	    return "$dir/master.adp"
	set dir [file dirname $dir]

    if { [file exists "$path_root/templates/master.adp"] } {
	return "$path_root/templates/master.adp"

    # Uhoh. Nada!
    return ""