public TreeNode fromPreInOrderBuilder(int[] preorder, int[] inorder, int prestart, int instart, int length) {
        if (length <= 0) return null;

        int topVal = preorder[prestart];
        int topInIndex = instart;
        for(int inIndexEnd=instart+length;topInIndex<inIndexEnd; topInIndex++) {
            if (inorder[topInIndex] == topVal) break;
        }
        // Should raise Exception if topInIndex is bigger than inIndexEnd
        int leftLength = topInIndex - instart;
        int rightLength = length - leftLength - 1;

        TreeNode top = new TreeNode(topVal);
        top.left = fromPreInOrderBuilder(preorder, inorder, prestart+1, instart, leftLength);
        top.right = fromPreInOrderBuilder(preorder, inorder, prestart+1+leftLength, instart+1+leftLength, rightLength);

        return top;
    }