def is_valid_interval(x):
    """
    Returns true iff x is a well-shaped concrete time interval (i.e. has valid beginning and end).
    """
    try:
        return hasattr(x, "hasBeginning") and len(x.hasBeginning) > 0 and \
               len(x.hasBeginning[0].inTimePosition) > 0 and \
               len(x.hasBeginning[0].inTimePosition[0].numericPosition) > 0 and hasattr(x, "hasEnd") and \
               len(x.hasEnd) > 0 and len(x.hasEnd[0].inTimePosition) > 0 and \
               len(x.hasEnd[0].inTimePosition[0].numericPosition) > 0 and \
               x.hasBeginning[0].inTimePosition[0].numericPosition < x.hasEnd[0].inTimePosition[0].numericPosition
    except TypeError:
        return False