def replace_tree_marks(key, arguments):
    """ Replace TREE markers from key to proper argument

    :param key: The currently processed key from .yaml file
    :param arguments: Arguments already typed for command
    :return: Key string with replaced marks
    """
    tree_mark_index = key.find('TREE~')
    while tree_mark_index >= 0:
        tree_index = -int(key[tree_mark_index + 5])
        key = key[:tree_mark_index] + arguments[tree_index] + key[
            tree_mark_index + 6:]
        tree_mark_index = key.find('TREE~')
    return key
