<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_file_id(credentials, gfile, write_access=False):
 """ Get file ID by provided path. If file does not exist and `write_access` is true, it will create whole path for you. :param credentials: provide own credentials :param gfile: path to Google Spreadsheet :param write_access: allows to create full path if file does not exist :type credentials: class 'oauth2client.client.OAuth2Credentials' :type gfile: str :type write_access: boolean :returns: file ID :rtype: str :Example: u'78asbcsSND8sdSACNsa7ggcasca8shscaSACVD' """

    # auth for apiclient
    http = credentials.authorize(Http())
    service = discovery.build('drive', 'v3', http=http, cache_discovery=False)

    file_id = service.files().get(fileId='root', fields='id').execute().get('id')

    # folder/folder/folder/spreadsheet
    pathway = gfile.strip('/').split('/')

    for idx, name in enumerate(pathway):
        files = service.files().list(
            q="name = '{}' and trashed = false and '{}' in parents".format(name, file_id)).execute()['files']
        if len(files) > 0:
            # Why do you ever need to use several folders with the same name?!
            file_id = files[0].get('id')
        elif write_access == True:
            body = {
                'mimeType': 'application/vnd.google-apps.' + ('spreadsheet' if idx == len(pathway)-1 else 'folder'),
                'name': name,
                'parents': [file_id]
            }
            file_id = service.files().create(body=body, fields='id').execute().get('id')
        else:
            return None
    return file_id