def resolve_possible_paths(path, relative_prefix, possible_extensions=None, leading_underscore=False):
    """
    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.
    """
    possible_extensions = [''] + list(possible_extensions) if possible_extensions else ['']
    possible_paths = [path + e if os.path.isabs(path + e) else os.path.join(relative_prefix, path + e)
                      for e in possible_extensions]

    if leading_underscore and not os.path.basename(path).startswith('_'):
        extra_paths = [os.path.join(os.path.dirname(p), '_' + os.path.basename(p))
                       for p in possible_paths]
        possible_paths = possible_paths + extra_paths

    for p in possible_paths:
        p = os.path.normpath(p)
        if os.path.isfile(p):
            return p

    return None
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.