def get_app(self, reference_app=None):
if reference_app is not None:<EOL><INDENT>return reference_app<EOL><DEDENT>if self.app is not None:<EOL><INDENT>return self.app<EOL><DEDENT>ctx = connection_stack.top<EOL>if ctx is not None:<EOL><INDENT>return ctx.app<EOL><DEDENT>raise RuntimeError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>
Helper method that implements the logic to look up an application.