// search root
CStation<?> rootStation = control.getStation( root );
if( rootStation == null ){
return null;
}
CStationContainer rootContainer = getContainer( rootStation );
if( rootContainer == null ){
return rootStation;
}
// search current container
CStation<?> station = getParent( dockable );
CStationContainer container = getContainer( station );
if( container != null ){
if( rootContainer == container ){
return rootStation;
}
return container.getMatchingStation( rootContainer, rootStation );
}
else{
List<Location> history = control.getLocationManager().getPropertyHistory( dockable );
for( int i = history.size()-1; i >= 0; i-- ){
String historyRoot = history.get( i ).getRoot();
CStation<?> historyStation = control.getStation( historyRoot );
if( historyStation != null ){
container = getContainer( historyStation );
if( container != null ){
CStation<?> result = container.getMatchingStation( rootContainer, rootStation );
if( result != null ){
return result;
}
}
}