def get_user_context(module_context, position):
    """
    Returns the scope in which the user resides. This includes flows.
    """
    leaf = module_context.tree_node.get_leaf_for_position(position,
        include_prefixes=True)
    return module_context.create_context(leaf)
