'Find parent scope, if the block is not a fold trigger.
:param block: block from which the research will start'

@staticmethod
def find_parent_scope(block):

    limit = 5000
    counter = 0
    original = block
    if (not TextBlockHelper.is_fold_trigger(block)):
        while ((block.text().strip() == '') and block.isValid()):
            block = block.next()
        ref_lvl = (TextBlockHelper.get_fold_lvl(block) - 1)
        block = original
        while (block.blockNumber() and (counter < limit) and ((not TextBlockHelper.is_fold_trigger(block)) or (TextBlockHelper.get_fold_lvl(block) > ref_lvl))):
            counter += 1
            block = block.previous()
    if (counter < limit):
        return block
    return None
