public function fromArray(array $array)
    {
        $root   = new Node(null);
        $map    = array();
        $map[0] = $root;

        // Create an entry in $map for every item in $a
        foreach ($array as $element) {
            if (3 !== count($element)) {
                throw new Exception('Each array must have 3 elements.');
            }

            $map[$element[0]] = new Node($element[2]);
        }

        //
        foreach ($array as $element) {
            if (empty($element[1])) {
                $element[1] = 0;
            }

            $found = false;
            $i     = 0;
            $keys  = array_keys($map);
            $cnt   = count($keys);
            while (!$found && $i < $cnt) {
                if ($keys[$i] === $element[1]) {
                    $map[$keys[$i]]->addChild($map[$element[0]]);
                    $found = true;
                } else {
                    $i++;
                }
            }
            if (!$found) {
                // Error
                throw new Exception('Data structure does not seem to be consistent. '
                        . 'Key "' . $element[1] . '" could not be found.');
            }
        }

        return $root;
    }