def execute_code_if(condition, code, glob=None, loc=None):
    """
    Execute code if condition is true

    Args:
        condition (bool): if true the code is executed
        code_if_obj_not_found (str): the code to be evaluated if the object has
             not been found.
        globals (dict): the global variables dictionary
        locals (dict): the local variables dictionary

    Returns:
         the object returned from the code executed, None otherwise
    """
    if not condition:
        return None
    if glob is None:
        glob = globals()
    if loc is None:
        loc = locals()
    return eval(code, glob, loc)