def _create_or_reuse_folder(local_folder, parent_folder_id,<EOL>reuse_existing=False):
local_folder_name = os.path.basename(local_folder)<EOL>folder_id = None<EOL>if reuse_existing:<EOL><INDENT>children = session.communicator.folder_children(<EOL>session.token, parent_folder_id)<EOL>folders = children['<STR_LIT>']<EOL>for folder in folders:<EOL><INDENT>if folder['<STR_LIT:name>'] == local_folder_name:<EOL><INDENT>folder_id = folder['<STR_LIT>']<EOL>break<EOL><DEDENT><DEDENT><DEDENT>if folder_id is None:<EOL><INDENT>new_folder = session.communicator.create_folder(session.token,<EOL>local_folder_name,<EOL>parent_folder_id)<EOL>folder_id = new_folder['<STR_LIT>']<EOL><DEDENT>return folder_id<EOL>
Create a folder from the local file in the midas folder corresponding to
the parent folder id.

:param local_folder: full path to a directory on the local file system
:type local_folder: string
:param parent_folder_id: id of parent folder on the Midas Server instance,
    where the folder will be added
:type parent_folder_id: int | long
:param reuse_existing: (optional) whether to accept an existing folder of
   the same name in the same location, or create a new one instead
:type reuse_existing: bool