def get_by_path(path, first=False):
api = get_api()<EOL>cur_res = api<EOL>parts = path.split('<STR_LIT::>')<EOL>for part in parts:<EOL><INDENT>res = getattr(cur_res, part, None)<EOL>if not res:<EOL><INDENT>res = find_by_name(cur_res, part)<EOL><DEDENT>cur_res = res<EOL><DEDENT>index = getattr(cur_res, '<STR_LIT:index>', None)<EOL>if index:<EOL><INDENT>return index()<EOL><DEDENT>return cur_res<EOL>
Search for resources using colon-separated path notation.

E.g.::

    path = 'deployments:production:servers:haproxy'
    haproxies = get_by_path(path)

:param bool first: Always use the first returned match for all intermediate
    searches along the path.  If this is ``False`` and an intermediate
    search returns multiple hits, an exception is raised.