def _visit_or_none(node, attr, visitor, parent, assign_ctx, visit='visit',
                   **kws):
    """If the given node has an attribute, visits the attribute, and
    otherwise returns None.

    """
    value = getattr(node, attr, None)
    if value:
        return getattr(visitor, visit)(value, parent, assign_ctx, **kws)
    else:
        return None