import re


def is_branch_or_version(string):
    """Tries to figure out if passed argument is branch or version.
    Returns 'branch', 'version', or False if deduction failed.
    Branch is either 'master' or something like 3.12.x;
    version is something like 3.12.5,
    optionally followed by letter (3.12.5b) for aplha/beta/gamma...zeta,
    optionally followed by release (3.12.5-2).
    """
    if string == "master" or re.match("3\.\\d+\.x$", string):
        return "branch"
    if re.match("3\\.\\d+\\.\\d+[a-z]?(-\\d+)?$", string):
        return "version"
    return None