Group within current group

Is there a way to reference a group within the currently selected group?

I have used this here

set theGroup to create location "/z PROJECTS DONE"

to reference groups within the currently selected database.

So how’d I reference a group that is in the currently selected (deeply nested) group?

Not sure where you’ve selected the group, whether in the Navigation Sidebar or in the Item List.

tell application id "DNtp"
	try
		#-- Window root
		#set theGroup to root of viewer window 1
		
		#-- Current group
		#set theGroup to current group
		
		-- Selected record
		set theRecords to selected records
		if theRecords = {} then error "Please select a group in the item list."
		
		if (type of (item 1 of theRecords) as string) is in {"group", "«constant DTgr»"} then
			set theGroup to item 1 of theRecords
			set theGroup_Name to name of theGroup
			if theGroup_Name contains "/" then set theGroup_Name to my escapeSlash(theGroup_Name)
			set theGroup_LocationAndName to (location of theGroup) & theGroup_Name
			
			set X to create location theGroup_LocationAndName & "/" & "Test"
		else
			error "Please select a group in the item list."
		end if
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
		return
	end try
end tell

on escapeSlash(theText)
	set d to AppleScript's text item delimiters
	set AppleScript's text item delimiters to "/"
	set theTextItems to every text item of theText
	set AppleScript's text item delimiters to "\\/"
	set theText_escaped to theTextItems as string
	set AppleScript's text item delimiters to d
	return theText_escaped
end escapeSlash