def get_vocabulary(query_tree):
    """Extracts the normalized search terms from the leaf nodes of a parsed
    query to construct the vocabulary for the text vectorization.

    Arguments
    ---------
    query_tree: pythonds.trees.BinaryTree
        The binary tree object representing a parsed search query. Each leaf
        node is a search term and internal nodes represent boolean operations.
        See parse_query() for details.

    Returns
    -------
    vocabulary: list
        List of strings representing unique normalized search terms.

    """
    def _getleafnodes(node):
        terms = []
        if node.isLeaf():
            return terms + [node.normedterm]
        elif node.leftChild and not node.rightChild:
            return terms + _getleafnodes(node.getLeftChild())
        elif node.rightChild and not node.leftChild:
            return terms + _getleafnodes(node.getRightChild())
        else:   # has two children
            return terms + _getleafnodes(node.getLeftChild()) \
                         + _getleafnodes(node.getRightChild())

    # extract terms from the leaf nodes of the query object.
    terms = _getleafnodes(query_tree)

    # remove duplicates.
    vocabulary = list(set(terms))

    return vocabulary