Locates files with a twist:

        * Check the existence of a file using the full path in `loc`

        * Search for the filename `loc` in `locations`

        * Create it's enclosing folders if the file does not exist. \
        use `create_in`

    :param loc:
        Filename to search
    :param locations:
        A list of possible locations to search within
        (can be a dictionary, see note below)
    :param critical:
        |appteardown| if file was not found
    :param create_in:
        If `loc` was not found, the folder `create_in` is created.
        If `locations` is a dictionary, `create_in` can also specify
        a key of `locations`. The value will be used then.
    :param verbose:
        Pass verbose flag to :func:`make_locations`
    :returns:
        The full path of `loc` in matched location

    .. note::
        * |params_locations_dict|

        * |param_locations_none|

def search_location(loc, locations=None,
                    critical=False, create_in=None, verbose=True):
    '''
    Locates files with a twist:

        * Check the existence of a file using the full path in `loc`

        * Search for the filename `loc` in `locations`

        * Create it's enclosing folders if the file does not exist. \
        use `create_in`

    :param loc:
        Filename to search
    :param locations:
        A list of possible locations to search within
        (can be a dictionary, see note below)
    :param critical:
        |appteardown| if file was not found
    :param create_in:
        If `loc` was not found, the folder `create_in` is created.
        If `locations` is a dictionary, `create_in` can also specify
        a key of `locations`. The value will be used then.
    :param verbose:
        Pass verbose flag to :func:`make_locations`
    :returns:
        The full path of `loc` in matched location

    .. note::
        * |params_locations_dict|

        * |param_locations_none|
    '''

    from photon.util.structures import to_list
    from photon.util.system import shell_notify

    if not locations:
        locations = get_locations()

    for p in reversed(sorted(to_list(locations))):
        f = _path.join(p, loc)
        if _path.exists(f):
            return f

    if _path.exists(_path.abspath(_path.expanduser(loc))):
        return _path.abspath(_path.expanduser(loc))

    if critical:
        shell_notify('could not locate', state=True, more=dict(
            file=loc, locations=locations
        ))

    if create_in:
        if isinstance(locations, dict):
            create_in = locations.get(create_in, create_in)
        make_locations(locations=[create_in], verbose=verbose)
        return _path.join(create_in, loc)