def np_chunk(tree):
    """
    Return a list of all noun phrase chunks in the sentence tree.
    A noun phrase chunk is defined as any subtree of the sentence
    whose label is "NP" that does not itself contain any other
    noun phrases as subtrees.
    """
    # Create a list to store the noun phrase chunks.
    noun_prhase_chunks = []

    # Iterate over the subtrees of 'tree'.
    for subtree in tree.subtrees():
        # For each 'subtree' iterate over its subtrees 's' adding the label
        # for each 's' to the list 'labels'.
        labels = []
        for s in subtree:
            # Use a try loop to try to add all the labels of each 's' to avoid
            # erros. Because at some point 's' might be a string, which doesn't
            # have a label method.
            try:
                labels.append(s.label())
            except:
                continue

        # A 'subtree' that is a noun phrase will not have subtrees 's' with
        # the label "NP".
        if subtree.label() == "NP" and "NP" not in [labels]:
            noun_prhase_chunks.append(subtree)

    return noun_prhase_chunks