Expands paths on a YAML document node. If it is a sequence node (list) items on the first level are expanded. For
    a mapping node (dict), values are expanded.

    :param loader: YAML loader.
    :type loader: yaml.loader.SafeLoader
    :param node: Document node.
    :type node: ScalarNode, MappingNode, or SequenceNode
    :param expand_method: Callable to expand the path with.
    :type expand_method: callable
    :return: Expanded value.
    :rtype: unicode | str | list | dict

def expand_node(loader, node, expand_method):
    """
    Expands paths on a YAML document node. If it is a sequence node (list) items on the first level are expanded. For
    a mapping node (dict), values are expanded.

    :param loader: YAML loader.
    :type loader: yaml.loader.SafeLoader
    :param node: Document node.
    :type node: ScalarNode, MappingNode, or SequenceNode
    :param expand_method: Callable to expand the path with.
    :type expand_method: callable
    :return: Expanded value.
    :rtype: unicode | str | list | dict
    """
    if isinstance(node, yaml.nodes.ScalarNode):
        val = loader.construct_scalar(node)
        return expand_method(val)
    elif isinstance(node, yaml.nodes.MappingNode):
        val = loader.construct_mapping(node)
        for d_key, d_val in six.iteritems(val):
            val[d_key] = expand_method(d_val)
        return val
    elif isinstance(node, yaml.nodes.SequenceNode):
        val = loader.construct_sequence(node)
        return [expand_method(l_val) for l_val in val]