public function index(callable $inOptDataIndexBuilder=null, $inOptUnique=true) {

        if (is_null($inOptDataIndexBuilder)) {
            $inOptDataIndexBuilder = $this->__dataIndexBuilder;
        }

        $index = [];
        $dataMaker = function(Node $inNode, array &$inOutResult) use ($inOptDataIndexBuilder, $inOptUnique) {
            // Add a new entry to the nodes' index.
            if ($inOptUnique) {
                $inOutResult[$inOptDataIndexBuilder($inNode->getData())] = $inNode;
            } else {
                $inOutResult[$inOptDataIndexBuilder($inNode->getData())][] = $inNode;
            }
        };
        $this->getRoot()->traverse($dataMaker, $index);
        return $index;
    }