def _get_user_ns_object(shell, path):
    """Get object from the user namespace, given a path containing
    zero or more dots.  Return None if the path is not valid.
    """
    parts = path.split('.', 1)
    name, attr = parts[0], parts[1:]
    if name in shell.user_ns:
        if attr:
            try:
                return _getattr(shell.user_ns[name], attr[0])
            except AttributeError:
                return None
        else:
            return shell.user_ns[name]
    return None
Get object from the user namespace, given a path containing
    zero or more dots.  Return None if the path is not valid.