def get_cmd_arg(arg, cmd_tree):
    """
    Return the indicated command argument from command parse tree. If arg is
    a str it is a keyword. If arg is an int it is a positional index. If
    the argument is not found, return None.

    Args:
        arg: Command argument to look up
        cmd_tree: Parsed command tree

    Returns:
        value: Value of the command argument or None if not found
    """
    value = None
    if isinstance(arg, int):
        node = cmd_tree.positional_value(arg)
        if node is not None:
            value = node.value
    elif isinstance(arg, str):
        if cmd_tree.keyword_exists(arg):
            value = cmd_tree.keyword_value(arg)[0].value
    else:
        assert False, ("get_cmd_arg(arg, cmd_tree): arg {} not an instance of"
                       " int or str".format(arg))
    return value