def get_subparsers(parser, create=False):
<EOL>if parser._subparsers:<EOL><INDENT>actions = [a for a in parser._actions<EOL>if isinstance(a, argparse._SubParsersAction)]<EOL>assert len(actions) == <NUM_LIT:1><EOL>return actions[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>if create:<EOL><INDENT>return parser.add_subparsers()<EOL><DEDENT><DEDENT>
Returns the :class:`argparse._SubParsersAction` instance for given
:class:`ArgumentParser` instance as would have been returned by
:meth:`ArgumentParser.add_subparsers`. The problem with the latter is that
it only works once and raises an exception on the second attempt, and the
public API seems to lack a method to get *existing* subparsers.

:param create:
    If `True`, creates the subparser if it does not exist. Default if
    `False`.