1. A method for resolving ambiguity in processing of a computer application having variables with variable declarations with dynamic variable scopes, the method comprising: representing the variable declarations with dynamic variable scopes of the computer application in a tree data structure, where nodes of the tree data structure are variable names of the computer application; when the computer application executes code or an event from a particular node in the tree data structure and asks for a value of the variable for the particular node but finds a searched variable name at two or more nodes of the tree data structure, a processor calculating weighted distances between a context node and two or more candidate nodes of the tree data structure, each candidate node containing the searched variable name, where the weighted distance equals a number of downward steps from the context node to a candidate node multiplied by a first constant plus a number of upward steps from the context node to the candidate node multiplied by a second constant; the processor selecting a node from the candidate nodes having a desired weighted distance; and the processor returning information from the selected node to the computer application as the value for the variable, wherein the tree data structure is derived from an XML tree structure of the computer application and the nodes are XML files within the computer application.