private static SplitContainer findBetterContainer(SplitContainer split, Container dockingPanel, boolean anchoredTop, boolean anchoredLeft, boolean anchoredBottom, boolean anchoredRight) {
		// we already have found a splitContainer, but it can be subOptimal in some cases
		// for instance when we want to anchor a component at the bottom of the container (full width),
		// and there are two horizontal splits there, we might return the internal split (not full width),
		// and not the external (full width) one.
		// this method will try to find a splitcontainer upper in the hierarchy, with better anchors
		/*System.out.println("global anchors " + anchoredTop + " "
		       + anchoredLeft + " " + anchoredBottom + " " + anchoredRight);*/
		boolean[] globalAnchors = {anchoredTop, anchoredLeft, anchoredBottom, anchoredRight};
		int globalCount = 0; // number of anchors to be found (at least)
		for(int i = 0; i < 4; i++) {
			if(globalAnchors[i]) {
				globalCount++;
			}
		}

		SplitContainer betterSplit = split;
		boolean[] splitAnchors = new boolean[4];
		while(true) {
			int contacts = findAnchors(split, dockingPanel);
			splitAnchors[0] = (contacts & AnchorConstraints.ANCHOR_TOP) > 0;
			splitAnchors[1] = (contacts & AnchorConstraints.ANCHOR_LEFT) > 0;
			splitAnchors[2] = (contacts & AnchorConstraints.ANCHOR_BOTTOM) > 0;
			splitAnchors[3] = (contacts & AnchorConstraints.ANCHOR_RIGHT) > 0;
			int count = 0;
			for(int i = 0; i < 4; i++) {
				if(globalAnchors[i] && splitAnchors[i]) {
					count++;
				}
			}
			if(count >= globalCount) {
				return split;
			} else {
				if(split.getParent() instanceof SplitContainer) {
					split = (SplitContainer) split.getParent();
				} else {
					return split; // last split container
				}
			}
		}
	}