function getVariableFromContext(context, node, name) {
  let scope = getScope(context, node);

  while (scope) {
    let variable = getVariable(scope.variables, name);

    if (!variable && scope.childScopes.length) {
      variable = getVariable(scope.childScopes[0].variables, name);

      if (!variable && scope.childScopes[0].childScopes.length) {
        variable = getVariable(scope.childScopes[0].childScopes[0].variables, name);
      }
    }

    if (variable) {
      return variable;
    }
    scope = scope.upper;
  }
  return undefined;
}
Searches for a variable in the given scope.

@param {Object} context The current rule context.
@param {ASTNode} node The node to start looking from.
@param {string} name The name of the variable to search.
@returns {Object | undefined} Variable if the variable was found, undefined if not.