function getVariableData(ancestors, variable) {
      let scope = vars;

      for (const node of ancestors) {
        scope = scope[node];

        if (scope[variable]) {
          return scope[variable];
        }
      }

      return {
        defaultCount: 0,
        isDeclared: false
      };
    }
Iterates through the ancestors while checking each scope until the [variable] is found.
If not found, an object with empty values is returned.
@param {*} ancestors
@param {string} variable the variable name.
@returns The previously declared variable data or an object with empty values.