<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_buildout_parts(buildout, query=None):
 """Return buildout parts matching the given query """

    parts = names = (buildout['buildout'].get('parts') or '').split('\n')
    for name in names:
        part = buildout.get(name) or {}
        for key, value in (query or {}).items():
            if value not in (part.get(key) or ''):
                parts.remove(name)
                break
    return parts