import re


def identifiable(mpt):
    """ Check for identifiability

    Parameters
    ----------
    mpt : MPT
        MPT to be checked for identifiability

    Returns
    -------
    boolean
        whether tree is identifiable

    """

    max_params = 0
    for subtree in mpt.subtrees:
        max_params += len(subtree) - 1

    free_params = [
        x for x in set(mpt.word.parameters) if not re.match(r'y\d+', x)
    ]

    return len(free_params) <= max_params