def _trimmed_text(node):
    """Returns the trimmed text contained in the given DOM node or None if
    empty or if node is None.
    """
    try:
        return node.text.strip() or None
    except AttributeError:
        return None