function getVariable(name, leafNode) {
  let node = leafNode

  while (node != null) {
    const variables = node.variables
    const variable = variables && variables.find((v) => v.id.name === name)

    if (variable != null) {
      return variable
    }

    if (node.parent.type === 'VDocumentFragment') {
      break
    }

    node = node.parent
  }

  return null
}
Get the variable by names.
@param {string} name The variable name to find.
@param {VElement} leafNode The node to look up.
@returns {VVariable|null} The found variable or null.