k-d tree bin packing algorithm in C#