What are the variables needed to access focus properties in split screen view? What are the names of the variables (in terms of Applescript variables or otherwise) that track the currently focused application, the layout of applications in spaces, the currently focused space, and whether two applications share a space in a split view rather than 2 applications appearing in a desktop?

How does one (given a variable identifying an application) assign focus to a particular window of that application if that window resides in a split screen view?

To make the reason for asking this question concrete: the goal is to write an Applescript (or other kind of script) that assigns a keyboard shortcut that rapidly allows swapping focus between two applications that share a split screen view?

The simplest algorithm I can think of for accomplishing this (since it appears to not be a built in setting) is to 


get list of current spaces (including desktops, full screen applications, and split screen applications)
get currently focused space
if currently focused space is assigned to split-screen applications, get list of those applications and application windows (each should be length 2). 
get currently focused application
assign focus to next element in the list of application windows in the currently focused split screen view (which should be the other application window in the currently focused split screen)


I'm not sure if this would work quite as well to solve the problem pointed out in Switch focus in split view regarding two windows of the same application, but at least this would be a start.
I've been searching for this answer for years, and I've become very good at tracking down hidden functionality... To no avail unfortunately. Apple has no mechanism for doing anything with spaces programmatically. The only facility I found is by running the defaults command and (under one of the defaults whose name I can't recall at the moment) there is an area that'll give you cryptic window numbers and the spaces they belong to. The issue is that list isn't updated live, so it isn't really that useful. I'm still searching, but I'm fairly certain there is no Apple-approved way to interact with spaces, or split screen, or any of its other manifestations.

EDIT: Oh yes, it's "com.apple.spaces". Run the command defaults read com.apple.spaces in the terminal to get to what I was talking about.

EDIT2: Also, there's a way to activate spaces with a little bit of C code:

CoreDockSendNotification(CFSTR("com.apple.expose.awake"));
CoreDockSendNotification(CFSTR("com.apple.expose.front.awake"));
CoreDockSendNotification(CFSTR("com.apple.showdesktop.awake"));


Each of these lines will make mission control do stuff, not that it's all that useful. There are other ways to do this...