This is minor, but the identifiers are confusing. For example, if we're looking for templates, why add a template to the template list as 'vm'. Vice versa for adding vms to the template list...

My suggestion, in untested code shot from the hip:
```python
# If desired, this if expression could be broken out into its verbose four-line version
prop_elemname = 'config.template' if get_template else 'name'
for prop in props:
    for elem in prop.PropSet:
        if elem.Name == prop_elemname:
            #formerly templates_list
            vm_or_templates.append(elem.Val)
            # stop going through this prop's elements after hitting a match on elem.Name
            break
return vm_or_templates
```