import ruamel.yaml as yaml
yaml_str = """treeroot:
    branch1:
        name: Node 1
        branch1-1:
            name: Node 1-1   
    branch2:
        name: Node 2
        branch2-1:
            name: Node 2-1
"""
data = yaml.load(yaml_str, Loader=yaml.RoundTripLoader)
How can I create a yaml file from pure python?