def METHOD_NAME(self, args, return_unknown):
    # add optional args with defaults
    arg_dest = []
    arg_vals = []
    for opt in self.opt:
        arg_dest.append(opt.dest)
        arg_vals.append(opt.default)
    # deal with unknown arguments, if needed
    unknown = []
    def consume_unknown():
        while args and not args[0].startswith("-"):
            unknown.append(args.pop(0))
    # parse all args
    parsed_pos = False
    while args or not parsed_pos:
        if args and args[0].startswith("-") and args[0] != "-" and args[0] != "--":
            # optional arg
            a = args.pop(0)
            if a in ("-h", "--help"):
                self.usage(True)
                sys.exit(0)
            found = False
            for i, opt in enumerate(self.opt):
                if a in opt.names:
                    arg_vals[i] = opt.parse(a, args)
                    found = True
                    break
            if not found:
                if return_unknown:
                    unknown.append(a)
                    consume_unknown()
                else:
                    raise _ArgError("unknown option %s" % a)
        else:
            # positional arg
            if parsed_pos:
                if return_unknown:
                    unknown = unknown + args
                    break
                else:
                    raise _ArgError("extra args: %s" % " ".join(args))
            for pos in self.pos:
                arg_dest.append(pos.dest)
                arg_vals.append(pos.parse(pos.names[0], args))
            parsed_pos = True
            if return_unknown:
                consume_unknown()
    # build and return named tuple with arg values
    values = namedtuple("args", arg_dest)(*arg_vals)
    return (values, unknown) if return_unknown else values