I'm not sure if I really understand your problem.
Starting with an API context on element 'level 2' (e.g. a context menu script), following some simple source code examples, that may help you.
level2; // node context
english = context.getProject().getLanguage("EN");
varFormData = level2.getFormData();
fieldOne = varFormData.get(english, "mySecondVariable");
fieldOne.get();
<overwritten value in level 2>
// throws NoSuchFormFieldException because variable 'myVariable' is not defined in node 'level 2' -> value is inherited
varFormData.get(english, "myVariable");
// get a list of valid field names (in this case names of variables defined in this formData)
fieldNames = varFormData.getForm().appendEditorNames(null);
// check wether a specific variable is declared in this formdata
GomFormElement editor = varFormData.getForm().findEditor("mySecondVariable");
print(editor != null);
<true>
editor = varFormData.getForm().findEditor("myVariable");
print(editor != null);
<false>
parentFormData = level2.getParent().getFormData();
editor = parentFormData.getForm().findEditor("myVariable");
print(editor != null);
<true>
if (editor != null) {
field = parentFormData.get(english, editor.getName().toString());
field.get();
<overwritten value in level 1>
}