def resolve_possible_paths(path, relative_prefix, possible_extensions=None, leading_underscore=False):
possible_extensions = ['<STR_LIT>'] + list(possible_extensions) if possible_extensions else ['<STR_LIT>']<EOL>possible_paths = [path + e if os.path.isabs(path + e) else os.path.join(relative_prefix, path + e)<EOL>for e in possible_extensions]<EOL>if leading_underscore and not os.path.basename(path).startswith('<STR_LIT:_>'):<EOL><INDENT>extra_paths = [os.path.join(os.path.dirname(p), '<STR_LIT:_>' + os.path.basename(p))<EOL>for p in possible_paths]<EOL>possible_paths = possible_paths + extra_paths<EOL><DEDENT>for p in possible_paths:<EOL><INDENT>p = os.path.normpath(p)<EOL>if os.path.isfile(p):<EOL><INDENT>return p<EOL><DEDENT><DEDENT>return None<EOL>
Attempts to resolve the given absolute or relative ``path``. If it
doesn't exist as is, tries to create an absolute path using the
``relative_prefix``. If that fails, tries relative/absolute versions
with each of ``possible_extensions``.

:returns: The absolute path, or ``None`` if no such file can be found.